Skip to content

Commit

Permalink
gracefully show errors during grainrun
Browse files Browse the repository at this point in the history
  • Loading branch information
ospencer committed Jan 11, 2023
1 parent 5583909 commit f3203ec
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions cli/bin/grainrun.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,15 @@ const wasi = new WASI({
const importObject = { wasi_snapshot_preview1: wasi.wasiImport };

async function run(filename) {
const wasm = await WebAssembly.compile(await readFile(filename));
const instance = await WebAssembly.instantiate(wasm, importObject);

wasi.start(instance);
try {
const wasm = await WebAssembly.compile(await readFile(filename));
const instance = await WebAssembly.instantiate(wasm, importObject);

wasi.start(instance);
} catch (err) {
console.error(err.stack);
process.exit(1);
}
}

run(argv[2]);

0 comments on commit f3203ec

Please sign in to comment.