Skip to content

Commit

Permalink
fix: catch error and bubble up
Browse files Browse the repository at this point in the history
  • Loading branch information
neurosnap committed May 7, 2024
1 parent 105cc1f commit 17b2c15
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions mdw/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,20 @@ export function loaderApi<
schema.loaders.success({ id: ctx.name, ...ctx.loader }),
schema.loaders.success({ id: ctx.key, ...ctx.loader }),
]);
} catch (err) {
const message = err?.message || "unknown exception";
yield* updateStore([
schema.loaders.error({
id: ctx.name,
message,
...ctx.loader,
}),
schema.loaders.error({
id: ctx.key,
message,
...ctx.loader,
}),
]);
} finally {
const loaders = yield* select((s: any) =>
schema.loaders.selectByIds(s, { ids: [ctx.name, ctx.key] })
Expand Down

0 comments on commit 17b2c15

Please sign in to comment.