hapijs / hapi-pino

🌲 Hapi plugin for the Pino logger
MIT License
148 stars 61 forks source link

Is a default failAction needed to log errors? #129

Open rgov opened 3 years ago

rgov commented 3 years ago

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?

mcollina commented 3 years ago

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

felixheck commented 3 years ago

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.