From 1e390e69cd45aeb4570fe821ef0ea866b71433e6 Mon Sep 17 00:00:00 2001 From: "Kevin (Kun) \"Kassimo\" Qian" Date: Wed, 26 Sep 2018 09:44:59 -0700 Subject: Error pretty print (print stack) --- js/console_test.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'js/console_test.ts') diff --git a/js/console_test.ts b/js/console_test.ts index cfe75dafe..94a627a5f 100644 --- a/js/console_test.ts +++ b/js/console_test.ts @@ -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"); + } +}); -- cgit v1.2.3