Skip to content

Commit 17b2c15

Browse files
committed
fix: catch error and bubble up
1 parent 105cc1f commit 17b2c15

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

mdw/store.ts

+14
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,20 @@ export function loaderApi<
183183
schema.loaders.success({ id: ctx.name, ...ctx.loader }),
184184
schema.loaders.success({ id: ctx.key, ...ctx.loader }),
185185
]);
186+
} catch (err) {
187+
const message = err?.message || "unknown exception";
188+
yield* updateStore([
189+
schema.loaders.error({
190+
id: ctx.name,
191+
message,
192+
...ctx.loader,
193+
}),
194+
schema.loaders.error({
195+
id: ctx.key,
196+
message,
197+
...ctx.loader,
198+
}),
199+
]);
186200
} finally {
187201
const loaders = yield* select((s: any) =>
188202
schema.loaders.selectByIds(s, { ids: [ctx.name, ctx.key] })

0 commit comments

Comments
 (0)