I want to format specific kinds of uncaught server errors
Answered
Kurilian Bobtail posted this in #help-forum
Kurilian BobtailOP
I am NOT interested in error boundaries (which are client-side only), error responses from API routes, or anything like that
I'm fine with an answer involving implementation details that might break tomorrow
I want to format specific kinds of uncaught exceptions that happen either in the pure node context or the RSC rendering context using my own custom JavaScript code. I want to be able to break on these errors by introducing a
In other words, I want to run code wherever nextjs processes exceptions. As far as I can tell, nextjs does not have this kind of feature.
In almost all cases, there is a function I can overwrite for doing this, like a function for internal exception formatting. Or maybe there is an (undocumented?) event I can listen to. If all else fails I can edit the source code somewhere. My question is where.
Alternatively, if I've missed this feature, please point me towards the documentation.
I'm fine with an answer involving implementation details that might break tomorrow
I want to format specific kinds of uncaught exceptions that happen either in the pure node context or the RSC rendering context using my own custom JavaScript code. I want to be able to break on these errors by introducing a
debugger
statement.In other words, I want to run code wherever nextjs processes exceptions. As far as I can tell, nextjs does not have this kind of feature.
In almost all cases, there is a function I can overwrite for doing this, like a function for internal exception formatting. Or maybe there is an (undocumented?) event I can listen to. If all else fails I can edit the source code somewhere. My question is where.
Alternatively, if I've missed this feature, please point me towards the documentation.
Answered by Kurilian Bobtail
well, I ended up searching for the emoji ⨯ and found that nextjs just logs errors to
console.error
so I just overwrite it and I get what I want1 Reply
Kurilian BobtailOP
well, I ended up searching for the emoji ⨯ and found that nextjs just logs errors to
console.error
so I just overwrite it and I get what I wantAnswer