Skip to content

Commit 5fd624a

Browse files
refactor: log critical never (#2015)
* refactor: log critical never * changeset --------- Co-authored-by: YaroShkvorets <[email protected]>
1 parent fefcf3b commit 5fd624a

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

.changeset/old-times-double.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphprotocol/graph-ts': patch
3+
---
4+
5+
changed log(CRITICAL) return type to `never` for compiler flow analysis

packages/ts/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,10 @@ export namespace log {
103103
* @param msg Format string a la "Value = {}, other = {}".
104104
* @param args Format string arguments.
105105
*/
106-
export function critical(msg: string, args: Array<string>): void {
107-
log.log(Level.CRITICAL, format(msg, args));
106+
export function critical(msg: string, args: Array<string>): never {
107+
const message = format(msg, args);
108+
log.log(Level.CRITICAL, message);
109+
throw new Error(message);
108110
}
109111

110112
/**

0 commit comments

Comments
 (0)