Error pretty print (print stack)

This commit is contained in:
Kevin (Kun) "Kassimo" Qian 2018-09-26 09:44:59 -07:00 committed by Ryan Dahl
parent 32806b1871
commit 1e390e69cd
2 changed files with 79 additions and 47 deletions

View file

@ -91,3 +91,17 @@ test(function consoleTestStringifyCircular() {
"Console { printFunc: [Function], debug: [Function: log], info: [Function: log], error: [Function: warn] }"
);
});
test(function consoleTestError() {
class MyError extends Error {
constructor(msg: string) {
super(msg);
this.name = "MyError";
}
}
try {
throw new MyError("This is an error");
} catch (e) {
assertEqual(stringify(e).split("\n")[0], "MyError: This is an error");
}
});