Skip to content

Commit 8455027

Browse files
committed
fix(davinci-client): remove try/catch from update dispatch — errors are now state
1 parent 3f8c83b commit 8455027

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
@@ -346,16 +346,8 @@ export async function davinci<ActionType extends ActionTypes = ActionTypes>({
346346
| FidoAuthenticationInputValue,
347347
index?: number,
348348
) {
349-
try {
350-
store.dispatch(nodeSlice.actions.update({ id, value, index }));
351-
return null;
352-
} catch (err) {
353-
const errorMessage = err instanceof Error ? err.message : String(err);
354-
return {
355-
type: 'internal_error',
356-
error: { message: errorMessage, type: 'internal_error' },
357-
};
358-
}
349+
store.dispatch(nodeSlice.actions.update({ id, value, index }));
350+
return null;
359351
};
360352
},
361353

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

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

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

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

0 commit comments

Comments
 (0)