Skip to content

Commit

Permalink
Check thrown type, print String(...) if not instance of error (denola…
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinkassimo authored and ry committed Oct 8, 2018
1 parent ffb41e6 commit 2b8cee9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions js/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ function onGlobalError(
source: string,
lineno: number,
colno: number,
error: Error
error: any // tslint:disable-line:no-any
) {
console.log(error.stack);
if (error instanceof Error) {
console.log(error.stack);
} else {
console.log(`Thrown: ${String(error)}`);
}
os.exit(1);
}

Expand Down
1 change: 1 addition & 0 deletions tests/error_007_any.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
throw {};
1 change: 1 addition & 0 deletions tests/error_007_any.ts.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Thrown: [object Object]

0 comments on commit 2b8cee9

Please sign in to comment.