summaryrefslogtreecommitdiff
path: root/runtime/js
diff options
context:
space:
mode:
authorInteon <42113979+inteon@users.noreply.github.com>2021-04-08 18:04:02 +0200
committerGitHub <noreply@github.com>2021-04-08 18:04:02 +0200
commitd050b491b10fe37b4461b37c56028a14c8674c95 (patch)
tree47aa768f3027dff90ffd1aacdd267274610bf441 /runtime/js
parentc4b21fbff119a8ce006391d8fb7586877759bcef (diff)
fix(core): error handling in examples (#9867)
Diffstat (limited to 'runtime/js')
-rw-r--r--runtime/js/12_io.js20
1 files changed, 2 insertions, 18 deletions
diff --git a/runtime/js/12_io.js b/runtime/js/12_io.js
index aa153e9fd..a6b6aeebd 100644
--- a/runtime/js/12_io.js
+++ b/runtime/js/12_io.js
@@ -82,9 +82,6 @@
}
const nread = core.binOpSync("op_read_sync", rid, buffer);
- if (nread < 0) {
- throw new Error("read error");
- }
return nread === 0 ? null : nread;
}
@@ -98,29 +95,16 @@
}
const nread = await core.binOpAsync("op_read_async", rid, buffer);
- if (nread < 0) {
- throw new Error("read error");
- }
return nread === 0 ? null : nread;
}
function writeSync(rid, data) {
- const result = core.binOpSync("op_write_sync", rid, data);
- if (result < 0) {
- throw new Error("write error");
- }
-
- return result;
+ return core.binOpSync("op_write_sync", rid, data);
}
async function write(rid, data) {
- const result = await core.binOpAsync("op_write_async", rid, data);
- if (result < 0) {
- throw new Error("write error");
- }
-
- return result;
+ return await core.binOpAsync("op_write_async", rid, data);
}
const READ_PER_ITER = 32 * 1024;