Next.js Discord

Discord Forum

error handling and error boundaries

Unanswered
Tonkinese posted this in #help-forum
Open in Discord
TonkineseOP
i have a (dumb) question
how do yall do error handling on the FE? (could be involving queries/mutations to the BE)

currently just have error boundaries rendering something when an error happens, however i absolutely don't like the DX because it completely replaces everything the user sees with an error

i'd prefer it if an error happened and the current UI is retained and some modal just pops up about the error, that'd be better of UX and easier to debug

1 Reply

@Tonkinese i have a (dumb) question how do yall do error handling on the FE? (could be involving queries/mutations to the BE) currently just have error boundaries rendering something when an error happens, however i absolutely don't like the DX because it completely replaces everything the user sees with an error i'd prefer it if an error happened and the current UI is retained and some modal just pops up about the error, that'd be better of UX and easier to debug
Yellowstripe scad
When it comes to forms, using something like react-hook-forms from NPM is a great solution, as it provides per field error handling.

When it comes to simple BE queries, fetches, mutations etc. I like to use server actions, and a transition, inside which I can listen for thrown errors coming from the Server Action, and call the right methods in place to bring up modals/notifications and display said error.