diff options
Diffstat (limited to 'cli/rt')
-rw-r--r-- | cli/rt/10_dispatch_json.js | 2 | ||||
-rw-r--r-- | cli/rt/10_dispatch_minimal.js | 18 |
2 files changed, 10 insertions, 10 deletions
diff --git a/cli/rt/10_dispatch_json.js b/cli/rt/10_dispatch_json.js index 05b4d46ed..4b244081a 100644 --- a/cli/rt/10_dispatch_json.js +++ b/cli/rt/10_dispatch_json.js @@ -21,7 +21,7 @@ function unwrapResponse(res) { if (res.err != null) { - throw new (core.getErrorClass(res.err.kind))(res.err.message); + throw new (core.getErrorClass(res.err.className))(res.err.message); } util.assert(res.ok != null); return res.ok; diff --git a/cli/rt/10_dispatch_minimal.js b/cli/rt/10_dispatch_minimal.js index 072285256..a843d4a9e 100644 --- a/cli/rt/10_dispatch_minimal.js +++ b/cli/rt/10_dispatch_minimal.js @@ -7,19 +7,20 @@ // Using an object without a prototype because `Map` was causing GC problems. const promiseTableMin = Object.create(null); + const decoder = new TextDecoder(); + // Note it's important that promiseId starts at 1 instead of 0, because sync // messages are indicated with promiseId 0. If we ever add wrap around logic for // overflows, this should be taken into account. let _nextPromiseId = 1; - const decoder = new TextDecoder(); - function nextPromiseId() { return _nextPromiseId++; } function recordFromBufMinimal(ui8) { - const header = ui8.subarray(0, 12); + const headerLen = 12; + const header = ui8.subarray(0, headerLen); const buf32 = new Int32Array( header.buffer, header.byteOffset, @@ -31,11 +32,10 @@ let err; if (arg < 0) { - const classLen = result; - const classAndMessage = decoder.decode(ui8.subarray(12)); - const errorClass = classAndMessage.slice(0, classLen); - const message = classAndMessage.slice(classLen); - err = { kind: errorClass, message }; + err = { + className: decoder.decode(ui8.subarray(headerLen, headerLen + result)), + message: decoder.decode(ui8.subarray(headerLen + result)), + }; } else if (ui8.length != 12) { throw new TypeError("Malformed response message"); } @@ -50,7 +50,7 @@ function unwrapResponse(res) { if (res.err != null) { - throw new (core.getErrorClass(res.err.kind))(res.err.message); + throw new (core.getErrorClass(res.err.className))(res.err.message); } return res.result; } |