Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): invalid scopes on module re-export #2341
- Loading branch information
1 parent
1167450
commit f210ebc
Showing
3 changed files
with
40 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,31 @@ | ||
import { ExceptionHandler } from './exception-handler'; | ||
import { UNHANDLED_RUNTIME_EXCEPTION } from './messages'; | ||
|
||
const DEFAULT_TEARDOWN = () => process.exit(1); | ||
|
||
export class ExceptionsZone { | ||
private static readonly exceptionHandler = new ExceptionHandler(); | ||
|
||
public static run(fn: () => void) { | ||
public static run( | ||
callback: () => void, | ||
teardown: (err: any) => void = DEFAULT_TEARDOWN, | ||
) { | ||
try { | ||
fn(); | ||
callback(); | ||
} catch (e) { | ||
this.exceptionHandler.handle(e); | ||
throw UNHANDLED_RUNTIME_EXCEPTION; | ||
teardown(e); | ||
} | ||
} | ||
|
||
public static async asyncRun(fn: () => Promise<void>) { | ||
public static async asyncRun( | ||
callback: () => Promise<void>, | ||
teardown: (err: any) => void = DEFAULT_TEARDOWN, | ||
) { | ||
try { | ||
await fn(); | ||
await callback(); | ||
} catch (e) { | ||
this.exceptionHandler.handle(e); | ||
throw UNHANDLED_RUNTIME_EXCEPTION; | ||
teardown(e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters