summaryrefslogtreecommitdiff
path: root/std/wasi/snapshot_preview1.ts
diff options
context:
space:
mode:
authorCasper Beyer <caspervonb@pm.me>2021-01-06 18:29:55 +0800
committerGitHub <noreply@github.com>2021-01-06 05:29:55 -0500
commitf4b03a8887ded3d75811e0bce3c39da3788365bb (patch)
tree0c5e747e585a088f40d49cf1b776caed50a3a3b0 /std/wasi/snapshot_preview1.ts
parent54240c22af6233d1d977d469868b0d9050cad6da (diff)
BREAKING(std/wasi): return exit code from start (#9022)
This returns the exit code directly from the start entry point instead of throwing it and letting the user handle it. As a result the exit status is an implementation detail and has been made internal.
Diffstat (limited to 'std/wasi/snapshot_preview1.ts')
-rw-r--r--std/wasi/snapshot_preview1.ts16
1 files changed, 13 insertions, 3 deletions
diff --git a/std/wasi/snapshot_preview1.ts b/std/wasi/snapshot_preview1.ts
index 1a17d1a3d..d4caa97bc 100644
--- a/std/wasi/snapshot_preview1.ts
+++ b/std/wasi/snapshot_preview1.ts
@@ -270,7 +270,7 @@ interface FileDescriptor {
entries?: Deno.DirEntry[];
}
-export class ExitStatus {
+class ExitStatus {
code: number;
constructor(code: number) {
@@ -1656,7 +1656,7 @@ export default class Context {
* which will be used as the address space, if it does not an error will be
* thrown.
*/
- start(instance: WebAssembly.Instance) {
+ start(instance: WebAssembly.Instance): null | number | never {
if (this.#started) {
throw new Error("WebAssembly.Instance has already started");
}
@@ -1683,7 +1683,17 @@ export default class Context {
);
}
- _start();
+ try {
+ _start();
+ } catch (err) {
+ if (err instanceof ExitStatus) {
+ return err.code;
+ }
+
+ throw err;
+ }
+
+ return null;
}
/**