You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I cannot confirm that the error throw behavior is the same as before.
So I tried to replicate the default error handler, but I find it's quite complicated to override since it's not easy to get the actionMetadata object in middleware.
Proposed solution
I would suggest providing an interface like this to override the default error handler.
exportclassCustomErrorHandler{handle(error:any,action: ActionMetadata|undefined,options: Action){// developer can customer behaviours here.}}
The text was updated successfully, but these errors were encountered:
If you add your own error handler it is quite different. You are basically registering a normal ExpressErrorMiddlewareInterface by using your own. The downside is of course you have no access to the action and options.
A possible solution would be to extend the thrown error by the metadata required for the default error handler and pass that to the custom error handler instead. We could create a new base class for errors with the processJsonError and processTextError methods included. That way the users can just use the built in stuff even in their custom error handlers if they choose to.
Description
Currently routing-controllers' defaultErrorHandler is enabled by default.
If I want to do some error logging and error filtering using middleware, it can only happen after the error is sent to the client.
error filtering example
I tried this approach
But I got some issues:
So I tried to replicate the default error handler, but I find it's quite complicated to override since it's not easy to get the actionMetadata object in middleware.
Proposed solution
I would suggest providing an interface like this to override the default error handler.
The text was updated successfully, but these errors were encountered: