- commit
- 17b2c15
- parent
- 105cc1f
- author
- Eric Bower
- date
- 2024-05-07 16:41:38 +0000 UTC
fix: catch error and bubble up
1 files changed,
+14,
-0
+14,
-0
1@@ -183,6 +183,20 @@ export function loaderApi<
2 schema.loaders.success({ id: ctx.name, ...ctx.loader }),
3 schema.loaders.success({ id: ctx.key, ...ctx.loader }),
4 ]);
5+ } catch (err) {
6+ const message = err?.message || "unknown exception";
7+ yield* updateStore([
8+ schema.loaders.error({
9+ id: ctx.name,
10+ message,
11+ ...ctx.loader,
12+ }),
13+ schema.loaders.error({
14+ id: ctx.key,
15+ message,
16+ ...ctx.loader,
17+ }),
18+ ]);
19 } finally {
20 const loaders = yield* select((s: any) =>
21 schema.loaders.selectByIds(s, { ids: [ctx.name, ctx.key] })