Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is a default failAction needed to log errors? #129

Open
rgov opened this issue Feb 3, 2021 · 2 comments
Open

Is a default failAction needed to log errors? #129

rgov opened this issue Feb 3, 2021 · 2 comments

Comments

@rgov
Copy link

rgov commented Feb 3, 2021

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
Copy link
Collaborator

mcollina commented Feb 4, 2021

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

@felixheck
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants