diff options
Diffstat (limited to 'std/wasi/snapshot_preview1.ts')
-rw-r--r-- | std/wasi/snapshot_preview1.ts | 16 |
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; } /** |