Skip to content

Commit 2d82907

Browse files
committed
update catch to catch the task to better demonstrate how the errors flow
1 parent f88fc35 commit 2d82907

File tree

2 files changed

+18
-20
lines changed

2 files changed

+18
-20
lines changed

src/examples/BetterWays.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,15 @@ export function ErrorHandling() {
7878
// handle errors like this:
7979
runTask({
8080
loadingId: 'error-handled',
81-
task: () =>
82-
mockAsyncError().catch(e => {
83-
// handle the error however you want
84-
notifications.show({
85-
color: 'red',
86-
message: e.message,
87-
icon: <IoMdAlert />,
88-
position: 'top-center',
89-
});
90-
}),
81+
task: () => mockAsyncError(),
82+
}).catch(e => {
83+
// handle the error here...
84+
notifications.show({
85+
color: 'red',
86+
message: e.message,
87+
icon: <IoMdAlert />,
88+
position: 'top-center',
89+
});
9190
});
9291
}
9392

src/examples/code-strings.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,15 @@ export const BetterWaysCode = {
6161
// handle errors like this:
6262
runTask({
6363
loadingId: 'error-handled',
64-
task: () =>
65-
mockAsyncError().catch(e => {
66-
// handle the error however you want
67-
notifications.show({
68-
color: 'red',
69-
message: e.message,
70-
icon: <IoMdAlert />,
71-
position: 'top-center',
72-
});
73-
}),
64+
task: () => mockAsyncError(),
65+
}).catch(e => {
66+
// handle the error here...
67+
notifications.show({
68+
color: 'red',
69+
message: e.message,
70+
icon: <IoMdAlert />,
71+
position: 'top-center',
72+
});
7473
});
7574
}
7675

0 commit comments

Comments
 (0)