Skip to content

Commit d453241

Browse files
committed
fix: fix get message from unknown error
1 parent 9643773 commit d453241

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

src/state.ts

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type {Point} from '@flatten-js/core';
22
import {isEqual} from 'es-toolkit';
3-
import type {Actor, MachineSnapshot} from 'xstate';
43
import {toast} from 'react-toastify';
4+
import type {Actor, MachineSnapshot} from 'xstate';
55
import {type HoverPoint, HtmlEvent, type Layer, type SnapPoint, type StateMetaData,} from './App.types';
66
import type {ScreenCanvasDrawController} from './drawControllers/screenCanvas.drawController';
77
import type {Entity} from './entities/Entity';
@@ -203,23 +203,27 @@ export const setActiveToolActor = (
203203

204204
activeToolActor = newToolActor;
205205
activeToolActor.subscribe({
206-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
207-
next: (state: MachineSnapshot<any, any, any, any, any, any, any, any>) => {
208-
const stateInstructions = Object.values(state?.getMeta() as Record<string, StateMetaData>)[0]
209-
?.instructions;
210-
211-
if (getLastStateInstructions() === stateInstructions) {
212-
return;
213-
}
214-
215-
setLastStateInstructions(stateInstructions || null);
216-
},
217-
error: (err) => {
218-
toast.error(`Error in tool actor: ${err?.message}`);
219-
console.error('Error in tool actor', {err, newToolActor});
206+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
207+
next: (state: MachineSnapshot<any, any, any, any, any, any, any, any>) => {
208+
const stateInstructions = Object.values(state?.getMeta() as Record<string, StateMetaData>)[0]
209+
?.instructions;
210+
211+
if (getLastStateInstructions() === stateInstructions) {
212+
return;
220213
}
221-
}
222-
);
214+
215+
setLastStateInstructions(stateInstructions || null);
216+
},
217+
error: (err) => {
218+
toast.error(
219+
`Error in tool actor: ${
220+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
221+
(err as any)?.message || 'unknown error'
222+
}`
223+
);
224+
console.error('Error in tool actor', { err, newToolActor });
225+
},
226+
});
223227
activeToolActor.start();
224228

225229
console.log('User clicked on tool: ', {
@@ -362,7 +366,7 @@ function trackUndoState(variable: StateVariable, value: any) {
362366
}
363367

364368
// Push the new undo state
365-
undoStack.push({variable: variable, value: value});
369+
undoStack.push({ variable: variable, value: value });
366370
}
367371

368372
function updateStates(undoState: UndoState) {

0 commit comments

Comments
 (0)