chore(core): optional args for registerErrorClass (#9602)

This commit is contained in:
Luca Casonato 2021-02-25 20:06:06 +01:00 committed by GitHub
parent aa47f8186c
commit 975705a649
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 11 deletions

View file

@ -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;
}