Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Allow to log data validation errors #121

Open
Gpx opened this issue Nov 8, 2016 · 5 comments
Open

Allow to log data validation errors #121

Gpx opened this issue Nov 8, 2016 · 5 comments
Labels

Comments

@Gpx
Copy link

Gpx commented Nov 8, 2016

When the data validation fails the error description gets returned in the response body. I need a way to also log the response. Currently my error handler gets executed only for 5xx errors. This is the code I'm using:

osprey.loadFile(path)
  .then(middleware => {
    const app = express()
    app.use(middleware, router)

    app.use((err, req, res, next) => {
      const message = `REQUEST\n=======\n\n${JSON.stringify(req.body)}\n\nERROR\n=====\n\n${err.stack}`
      console.error(message)
      res.status(500).send(`REQUEST\n=======\n\n${req.body}\n\nERROR\n=====\n\n${err.stack}`)
    })

    app.listen(PORT, () => {
      console.log(`Server listening on port ${PORT}`)
    })
  })
  .catch(e => console.error("Error: %s", e.message))
@zero51
Copy link

zero51 commented Jan 25, 2017

@Gpx I'm having a similar issue. Did you find a fix?

@Gpx
Copy link
Author

Gpx commented Jan 25, 2017

I did not unfortunately

@zero51
Copy link

zero51 commented Jan 25, 2017

Thanks @Gpx. Is this a known issue @jstoiko?

@jstoiko
Copy link
Contributor

jstoiko commented Jan 25, 2017

Have you tried passing the disableErrorInterception option? See what it does here.

@zero51
Copy link

zero51 commented Jan 27, 2017

@jstoiko Perfect! Thanks!

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

No branches or pull requests

3 participants