summaryrefslogtreecommitdiff
path: root/core/01_core.js
diff options
context:
space:
mode:
Diffstat (limited to 'core/01_core.js')
-rw-r--r--core/01_core.js13
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;
}