BackendStack21 / restana

Restana is a lightweight and fast Node.js framework for building RESTful APIs.
MIT License
467 stars 27 forks source link

Improve error handling #38

Closed jkyberneees closed 5 years ago

jkyberneees commented 5 years ago

Supporting global error handler overwrite:

const service = require('restana')({
  errorHandler (err, req, res) {
    console.log(`Unexpected error: ${err.message}`)
    res.send(err)
  }
})

service.get('/throw', (req, res) => {
  throw new Error('Upps!')
})

service.start()