diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2022-08-11 10:57:20 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-11 11:57:20 +0200 |
commit | 25a1cc1b28ee2f37deb6305c0feb66d4eec50804 (patch) | |
tree | 4ddbedaaeb9fe30845e1e617df73a677d0d196c3 /core/01_core.js | |
parent | 321a42d1fbab8dd8869749b44b560bbbc4f5872a (diff) |
refactor(core): unwrap sync ops in rust (#15449)
Diffstat (limited to 'core/01_core.js')
-rw-r--r-- | core/01_core.js | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/core/01_core.js b/core/01_core.js index 0e823f54a..1dfb88c99 100644 --- a/core/01_core.js +++ b/core/01_core.js @@ -127,6 +127,18 @@ errorMap[className] = errorBuilder; } + function buildCustomError(className, message, code) { + const error = errorMap[className]?.(message); + // Strip buildCustomError() calls from stack trace + if (typeof error == "object") { + ErrorCaptureStackTrace(error, buildCustomError); + if (code) { + error.code = code; + } + } + return error; + } + function unwrapOpResult(res) { // .$err_class_name is a special key that should only exist on errors if (res?.$err_class_name) { @@ -168,7 +180,7 @@ } function opSync(opName, ...args) { - return unwrapOpResult(ops[opName](...args)); + return ops[opName](...args); } function refOp(promiseId) { @@ -229,6 +241,7 @@ metrics, registerErrorBuilder, registerErrorClass, + buildCustomError, opresolve, BadResource, BadResourcePrototype, |