Best practice for error handling
I am thrilled that tanstack start offers a bunch of options for error handling and I need to get my head around this.
I wonder what is the best practice for this scenario:
1. Option:
Error handling in server function and providing a graceful fallback with empty data result
2. Option:
Error handling in the route with onError
2 Replies
generous-apricot•3d ago
I just noticed that the custom error message doesn’t make it through when throwing inside a server function. I’m wondering if the same thing happens to you, or if you can actually see the error message in the browser when it comes from a server function?
https://discord.com/channels/719702312431386674/1442369658702397581
rising-crimson•3d ago
option 1 gives you a lot more flexibility in your stack IMO, as you could have situations where a full component on error might not be what you want.
you can also still throw an error from server side and it will propagate back down