hapi-pino icon indicating copy to clipboard operation
hapi-pino copied to clipboard

Is a default failAction needed to log errors?

Open rgov opened this issue 4 years ago • 2 comments

I'm completely new to Hapi, I'm just trying to contribute to another project that uses it.

If I am using hapi-pino, is it useful to have a default route.options.response.failAction like the following:

    routes: {
      response: {
        failAction: (request, h, err) => {
          request.log(['error'], err);
          return Boom.badRequest();
        }
      }
    }

Or without this default failAction, will errors still be captured by hapi-pino?

rgov avatar Feb 03 '21 17:02 rgov

I do not know. I'm not really an Hapi user myself anymore.

mcollina avatar Feb 04 '21 08:02 mcollina

IIRC errors are captured even without failAction, e.g. in case of internal server errors, internal accept-encoding errors, or failed requests. In such cases, the event's error object is available via the err property.

felixheck avatar Feb 08 '21 13:02 felixheck