diff options
author | Aaron O'Mullan <aaron.omullan@gmail.com> | 2021-10-07 18:39:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-07 18:39:27 +0200 |
commit | 370c27e09a63ca36f0e0aba8bef6b10f4484d70d (patch) | |
tree | 631924fc770337900bcd0d6abd5943f13a241f42 /core/01_core.js | |
parent | ab2e0a465e4eafe4de2cc6ac7ef61d1655db4c2d (diff) |
feat(core): cleaner opcall stack traces (#12358)
Diffstat (limited to 'core/01_core.js')
-rw-r--r-- | core/01_core.js | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/core/01_core.js b/core/01_core.js index 5af352340..e1b0529f7 100644 --- a/core/01_core.js +++ b/core/01_core.js @@ -12,6 +12,7 @@ Map, Array, ArrayPrototypeFill, + ErrorCaptureStackTrace, Promise, ObjectFreeze, ObjectFromEntries, @@ -113,12 +114,12 @@ if (res?.$err_class_name) { const className = res.$err_class_name; const errorBuilder = errorMap[className]; - if (!errorBuilder) { - throw new Error( - `Unregistered error class: "${className}"\n ${res.message}\n Classes of errors returned from ops should be registered via Deno.core.registerErrorClass().`, - ); - } - throw errorBuilder(res.message); + const err = errorBuilder ? errorBuilder(res.message) : new Error( + `Unregistered error class: "${className}"\n ${res.message}\n Classes of errors returned from ops should be registered via Deno.core.registerErrorClass().`, + ); + // Strip unwrapOpResult() and errorBuilder() calls from stack trace + ErrorCaptureStackTrace(err, unwrapOpResult); + throw err; } return res; } |