How to override custom error handler
See original GitHub issueI like the request methods this plugin adds, but how would like to handle the errors myself. How do I override the custom error handler? I’ve tried to add it after and before registering this plugin, but it never gets called;
fastify.setErrorHandler(function (error, request, reply) {
// Never called here...
})
fastify.register(require('fastify-sensible'))
fastify.setErrorHandler(function (error, request, reply) {
// Never called here...
})
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (7 by maintainers)
Top Results From Across the Web
Customize error handler - Optimizely
Here is a code example where an error handler from the SDK is used. If the error handler is not overridden, a no-op...
Read more >Angular override global ErrorHandler - Stack Overflow
We divide between the errors and then handle them with a service. handleError(error: any): void { const errorService = this.injector.
Read more >Custom Error Handling | Advanced Topics | Flow - Vaadin
In order to do so, first create your custom ErrorHandler class, then use that class to override the default error handler via VaadinSession.getCurrent()....
Read more >Custom Error Message Handling for REST API - Baeldung
Note that we are overriding a base method out of the ResponseEntityExceptionHandler and providing our own custom implementation.
Read more >Get Started with Custom Error Handling in Spring Boot (Java)
Learn how to implement custom error handling logic in Spring Boot. You will see two approaches based on the @ControllerAdvice annotation.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ve just added a test about this 😃 https://github.com/fastify/fastify-sensible/blob/535039664e5520b82aa0fa10c0194984a969265f/test/errorHandler.test.js#L108-L136
Hi! The plugins are registered asynchronously, while the custom error handler is not.
This should fix your issue 😃