Any repo example of perfect error handling using RSCs?
Unanswered
Black-tailed Gnatcatcher posted this in #help-forum
Black-tailed GnatcatcherOP
as title says, thank you!
5 Replies
@Black-tailed Gnatcatcher as title says, thank you!
No repo needed. Just return an error component for expected errors and use the
error.ts to handle unexpected errors. Attached you can see an easy example@B33fb0n3 No repo needed. Just return an error component for expected errors and use the `error.ts` to handle unexpected errors. Attached you can see an easy example
Black-tailed GnatcatcherOP
my backend engineer wants me to use try catches everywhere, is it non-sense?
(thanks for the example code will be useful)
@Black-tailed Gnatcatcher my backend engineer wants me to use try catches everywhere, is it non-sense?
that would work, when you throw the error. But when he throws the error, he need to also handle the error correctly (for example by setting the correct status code or by setting the error message). That can then be read by you (like I am doing with
Your backend dev might work differently and maybe always return you json, then it#s a bit different for you
request.ok and getting the error message by using .text())Your backend dev might work differently and maybe always return you json, then it#s a bit different for you
Black-tailed GnatcatcherOP
aight thanks for the help, have a good one