diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/core.js | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/core/core.js b/core/core.js index bda6739a2..fead23907 100644 --- a/core/core.js +++ b/core/core.js @@ -174,15 +174,15 @@ SharedQueue Binary Layout return send(opsCache[opName], control, ...zeroCopy); } - function registerErrorClass(errorName, className) { + function registerErrorClass(errorName, className, args) { if (typeof errorMap[errorName] !== "undefined") { throw new TypeError(`Error class for "${errorName}" already registered`); } - errorMap[errorName] = className; + errorMap[errorName] = [className, args ?? []]; } - function getErrorClass(errorName) { - return errorMap[errorName]; + function getErrorClassAndArgs(errorName) { + return errorMap[errorName] ?? [undefined, []]; } // Returns Uint8Array @@ -203,13 +203,13 @@ SharedQueue Binary Layout if ("ok" in res) { return res.ok; } - const ErrorClass = getErrorClass(res.err.className); + const [ErrorClass, args] = 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); } async function jsonOpAsync(opName, args = null, ...zeroCopy) { @@ -262,7 +262,7 @@ SharedQueue Binary Layout close, resources, registerErrorClass, - getErrorClass, + getErrorClassAndArgs, sharedQueueInit: init, // sharedQueue is private but exposed for testing. sharedQueue: { |