diff --git a/components/src/stores/vm.store.ts b/components/src/stores/vm.store.ts index 48f8cbd0..e676fe5b 100644 --- a/components/src/stores/vm.store.ts +++ b/components/src/stores/vm.store.ts @@ -102,7 +102,10 @@ function reduceVMTest( try { stack = vmTest.vm.vmStack().reverse(); } catch (e) { - setStatus("Runtime error: Invalid stack"); + dispatch.current({ + action: "setError", + payload: new Error("Runtime error: Invalid stack"), + }); } return { @@ -374,7 +377,7 @@ export function makeVmStore( return done; } catch (e) { setStatus(`Runtime error: ${(e as Error).message}`); - dispatch.current({ action: "setValid", payload: false }); + dispatch.current({ action: "setError", payload: e }); return true; } }, @@ -395,10 +398,11 @@ export function makeVmStore( if (animate) { dispatch.current({ action: "update" }); } + return done; } catch (e) { setStatus(`Runtime error: ${(e as Error).message}`); - dispatch.current({ action: "setValid", payload: false }); + dispatch.current({ action: "setError", payload: e }); return true; } }, diff --git a/web/src/pages/vm.tsx b/web/src/pages/vm.tsx index ede3c6f9..80fc6afd 100644 --- a/web/src/pages/vm.tsx +++ b/web/src/pages/vm.tsx @@ -252,28 +252,25 @@ const VM = () => { actions.setVm(source); }} language={"vm"} - highlight={ - state.controls.valid && state.vm.showHighlight - ? state.vm.highlight - : undefined - } + highlight={state.vm.showHighlight ? state.vm.highlight : undefined} + highlightType={state.controls.valid ? "highlight" : "error"} error={state.controls.error} /> VM Structures}> - {state.controls.valid && state.vm.Stack.length > 0 && ( - <> + <> + {state.vm.Stack.length > 0 && ( - - - )} + )} + +