Skip to content

Commit

Permalink
feat: throw error after effect hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
LiJun committed Jan 2, 2020
1 parent 122fcca commit 9a871b0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,13 @@ function createStore<
}
});
await Promise.all(ps);
const result = await originalEffect(effectFn, payload, extra);
let result = null;
let error = null;
try {
result = await originalEffect(effectFn, payload, extra);
} catch (e) {
error = e;
}
ps = [];
produce<any, any>(result, (res: any) => {
for (const afterEffect of hookMap.afterEffect as Array<
Expand All @@ -119,6 +125,9 @@ function createStore<
}
});
await Promise.all(ps);
if (error) {
throw error;
}
return result;
};
});
Expand Down

0 comments on commit 9a871b0

Please sign in to comment.