diff options
author | Alex Browne <stephenalexbrowne@gmail.com> | 2018-11-09 03:38:37 +0800 |
---|---|---|
committer | Alex Browne <stephenalexbrowne@gmail.com> | 2018-12-05 06:24:48 +0800 |
commit | 410a9244952b663fa8e56cc778b712ae228bbd82 (patch) | |
tree | ef9951abc2c867596c23bce159aca6f3536efe65 /packages/pipeline/src/utils | |
parent | 53cc9e9bedc6adf2247a190dbb758c9411033cab (diff) | |
download | dexon-sol-tools-410a9244952b663fa8e56cc778b712ae228bbd82.tar dexon-sol-tools-410a9244952b663fa8e56cc778b712ae228bbd82.tar.gz dexon-sol-tools-410a9244952b663fa8e56cc778b712ae228bbd82.tar.bz2 dexon-sol-tools-410a9244952b663fa8e56cc778b712ae228bbd82.tar.lz dexon-sol-tools-410a9244952b663fa8e56cc778b712ae228bbd82.tar.xz dexon-sol-tools-410a9244952b663fa8e56cc778b712ae228bbd82.tar.zst dexon-sol-tools-410a9244952b663fa8e56cc778b712ae228bbd82.zip |
Add better error handling for immediately invoked async functions
Diffstat (limited to 'packages/pipeline/src/utils')
-rw-r--r-- | packages/pipeline/src/utils/index.ts | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/packages/pipeline/src/utils/index.ts b/packages/pipeline/src/utils/index.ts index ebc1f8e0f..4242e0437 100644 --- a/packages/pipeline/src/utils/index.ts +++ b/packages/pipeline/src/utils/index.ts @@ -6,3 +6,17 @@ export function bigNumbertoStringOrNull(n: BigNumber): string | null { } return n.toString(); } + +export function handleError(e: any): void { + if (e.message != null) { + console.error(e.message); + } else { + console.error('Unknown error'); + } + if (e.stack != null) { + console.error(e.stack); + } else { + console.error('(No stack trace)'); + } + process.exit(1); +} |