mirror of
https://github.com/denoland/deno.git
synced 2025-09-27 04:39:10 +00:00
feat(core): cleaner opcall stack traces (#12358)
This commit is contained in:
parent
ab2e0a465e
commit
370c27e09a
2 changed files with 17 additions and 7 deletions
|
@ -1,4 +1,9 @@
|
||||||
import { assertStringIncludes, unitTest, unreachable } from "./test_util.ts";
|
import {
|
||||||
|
assert,
|
||||||
|
assertStringIncludes,
|
||||||
|
unitTest,
|
||||||
|
unreachable,
|
||||||
|
} from "./test_util.ts";
|
||||||
|
|
||||||
unitTest(async function sendAsyncStackTrace() {
|
unitTest(async function sendAsyncStackTrace() {
|
||||||
const buf = new Uint8Array(10);
|
const buf = new Uint8Array(10);
|
||||||
|
@ -11,6 +16,10 @@ unitTest(async function sendAsyncStackTrace() {
|
||||||
console.log(s);
|
console.log(s);
|
||||||
assertStringIncludes(s, "opcall_test.ts");
|
assertStringIncludes(s, "opcall_test.ts");
|
||||||
assertStringIncludes(s, "read");
|
assertStringIncludes(s, "read");
|
||||||
|
assert(
|
||||||
|
!s.includes("deno:core"),
|
||||||
|
"opcall stack traces should NOT include deno:core internals such as unwrapOpResult",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
Map,
|
Map,
|
||||||
Array,
|
Array,
|
||||||
ArrayPrototypeFill,
|
ArrayPrototypeFill,
|
||||||
|
ErrorCaptureStackTrace,
|
||||||
Promise,
|
Promise,
|
||||||
ObjectFreeze,
|
ObjectFreeze,
|
||||||
ObjectFromEntries,
|
ObjectFromEntries,
|
||||||
|
@ -113,12 +114,12 @@
|
||||||
if (res?.$err_class_name) {
|
if (res?.$err_class_name) {
|
||||||
const className = res.$err_class_name;
|
const className = res.$err_class_name;
|
||||||
const errorBuilder = errorMap[className];
|
const errorBuilder = errorMap[className];
|
||||||
if (!errorBuilder) {
|
const err = errorBuilder ? errorBuilder(res.message) : new Error(
|
||||||
throw new Error(
|
|
||||||
`Unregistered error class: "${className}"\n ${res.message}\n Classes of errors returned from ops should be registered via Deno.core.registerErrorClass().`,
|
`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
|
||||||
throw errorBuilder(res.message);
|
ErrorCaptureStackTrace(err, unwrapOpResult);
|
||||||
|
throw err;
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue