Skip to content

Commit

Permalink
Handle another source of emulator errors
Browse files Browse the repository at this point in the history
The unhandledrejection event handler from 89cb333
is not triggered when it exists with a non-0 status code (after successfully
booting, e.g. when trying to run MacWrite 1.0 on a too-modern OS).
  • Loading branch information
mihaip committed Mar 19, 2023
1 parent 5776e75 commit b39ff3c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/emulator/emulator-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,19 @@ function startEmulator(config: EmulatorWorkerConfig) {
},

printErr: console.warn.bind(console),

quit(status: number, toThrow?: Error) {
console.log("Emulator quit with status", status);
if (status !== 0) {
console.error(toThrow);
postMessage({
type: "emulator_did_have_error",
error: toThrow
? toThrow.toString()
: `Exit status ${status}`,
});
}
},
};
(self as any).Module = moduleOverrides;

Expand Down
4 changes: 4 additions & 0 deletions src/react-app-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,7 @@ declare module "ringbuf.js" {
available_write(): number;
}
}

interface EmscriptenModule {
quit: (status: number, toThrow?: Error) => void;
}

0 comments on commit b39ff3c

Please sign in to comment.