Check thrown type, print String(...) if not instance of error (#939)

Fixes #935
This commit is contained in:
Kevin (Kun) "Kassimo" Qian 2018-10-08 08:36:09 -07:00 committed by Ryan Dahl
parent ffb41e61f1
commit 2b8cee9a49
3 changed files with 8 additions and 2 deletions

View file

@ -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);
}

1
tests/error_007_any.ts Normal file
View file

@ -0,0 +1 @@
throw {};

View file

@ -0,0 +1 @@
Thrown: [object Object]