From e3eae662f3d753141571bd132ccb199f95c745ea Mon Sep 17 00:00:00 2001 From: Nayeem Rahman Date: Mon, 6 Jun 2022 19:26:57 +0100 Subject: fix: Format non-error exceptions (#14604) This commit adds "Deno.core.setFormatExceptionCallback" which can be used to provide custom formatting for errors. It is useful in cases when user throws something that is non-Error (eg. a string, plain object, etc). --- runtime/js/40_testing.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'runtime/js/40_testing.js') diff --git a/runtime/js/40_testing.js b/runtime/js/40_testing.js index 8c7d69fb0..865482042 100644 --- a/runtime/js/40_testing.js +++ b/runtime/js/40_testing.js @@ -217,14 +217,16 @@ let msg = `Test case is leaking async ops. -- ${ArrayPrototypeJoin(details, "\n - ")}`; + - ${ArrayPrototypeJoin(details, "\n - ")}`; if (!core.isOpCallTracingEnabled()) { msg += `\n\nTo get more details where ops were leaked, run again with --trace-ops flag.`; + } else { + msg += "\n"; } - throw msg; + throw assert(false, msg); }; } -- cgit v1.2.3