Next.js Discord

Discord Forum

How are we supposed to show SSR errors to users

Unanswered
Southeastern blueberry bee posted this in #help-forum
Open in Discord
Southeastern blueberry beeOP
In my app i have routes that might generate errors during ssr fetching of another api, i want to be able to show the user errors based off what happened, for example when a 403/401 error appears i want to be able to tell the user to login/they can't access the route.

Currently there doesn't seem to be a way to do this "easily" or in a way that doesn't involve 10 if check and try catches in every single route, i had planned to create an abstraction over the api by returning a "result" type similar to rust, where in the error there is a parsed error that includes the reason, status code and more info that i can show the user, but then how do i propagate it back to the user? What's the proper way to do this?

0 Replies