Skip to content

Commit 45a79f0

Browse files
committed
fix(davinci-client): remove try/catch from update dispatch — errors are now state
1 parent 12c2c65 commit 45a79f0

2 files changed

Lines changed: 7 additions & 12 deletions

File tree

packages/davinci-client/src/lib/client.store.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -345,16 +345,8 @@ export async function davinci<ActionType extends ActionTypes = ActionTypes>({
345345
| FidoAuthenticationInputValue,
346346
index?: number,
347347
) {
348-
try {
349-
store.dispatch(nodeSlice.actions.update({ id, value, index }));
350-
return null;
351-
} catch (err) {
352-
const errorMessage = err instanceof Error ? err.message : String(err);
353-
return {
354-
type: 'internal_error',
355-
error: { message: errorMessage, type: 'internal_error' },
356-
};
357-
}
348+
store.dispatch(nodeSlice.actions.update({ id, value, index }));
349+
return null;
358350
};
359351
},
360352

packages/davinci-client/src/lib/node.reducer.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ describe('The node collector reducer', () => {
349349
]);
350350
});
351351

352-
it('should throw with no collectors', () => {
352+
it('should add an UnknownCollector with error when no matching collector is found', () => {
353353
const action = {
354354
type: 'node/update',
355355
payload: {
@@ -377,7 +377,10 @@ describe('The node collector reducer', () => {
377377
},
378378
},
379379
];
380-
expect(() => nodeCollectorReducer(state, action)).toThrowError('No collector found to update');
380+
const result = nodeCollectorReducer(state, action);
381+
const errorCollector = result.find((c) => c.id === 'submit-1');
382+
expect(errorCollector?.error).toBe('No collector found to update');
383+
expect(errorCollector?.category).toBe('UnknownCollector');
381384
});
382385

383386
it('should set error on ActionCollector when update is attempted', () => {

0 commit comments

Comments
 (0)