fastify.setErrorHandler is not working.

Created on 16 May 2020  路  2Comments  路  Source: fastify/fastify

馃挜 Regression Report

fastify.setErrorHandler is not working.

Last working version

That's my first version. I'm new guy here.

To Reproduce

Steps to reproduce the behavior:

fastify.setErrorHandler((error, request, reply) => {
    reply.send(`Internal Server Error - ${error}`);
})

fastify.get('/err', async (req,reply) =>{
    return new Error('my error!')
})

Expected behavior

didn't catch the Error

{
"statusCode":500,
"error":"Internal Server Error",
"message":"Something went wrong"
}

Your Environment

  • node version: 10, 16, 0
  • fastify version: >=2.0.0
  • os:Windows
need info stale

Most helpful comment

I think you have fastify-sensible installed, if so, you should register it like this

fastify.register(require('fastify-sensible'), { errorHandler: false } )

Because it is hiding your error handler.

Moreover, you should throw error throw new Error('my error!') in async functions

All 2 comments

I think you have fastify-sensible installed, if so, you should register it like this

fastify.register(require('fastify-sensible'), { errorHandler: false } )

Because it is hiding your error handler.

Moreover, you should throw error throw new Error('my error!') in async functions

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rqbazan picture rqbazan  路  3Comments

kojilab picture kojilab  路  3Comments

allevo picture allevo  路  3Comments

valentinvichnal picture valentinvichnal  路  3Comments

mcollina picture mcollina  路  4Comments