mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
chore(core): optional args for registerErrorClass (#9602)
This commit is contained in:
parent
aa47f8186c
commit
975705a649
4 changed files with 16 additions and 11 deletions
|
@ -51,13 +51,13 @@
|
|||
|
||||
function unwrapResponse(res) {
|
||||
if (res.err != null) {
|
||||
const ErrorClass = core.getErrorClass(res.err.className);
|
||||
const [ErrorClass, args] = core.getErrorClassAndArgs(res.err.className);
|
||||
if (!ErrorClass) {
|
||||
throw new Error(
|
||||
`Unregistered error class: "${res.err.className}"\n ${res.err.message}\n Classes of errors returned from ops should be registered via Deno.core.registerErrorClass().`,
|
||||
);
|
||||
}
|
||||
throw new ErrorClass(res.err.message);
|
||||
throw new ErrorClass(res.err.message, ...args);
|
||||
}
|
||||
return res.result;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue