error handling
Introduction
Error handling is done mostly by throwing a new Error. Each route is wrapped with a try/catch block so that you can safely throw at any point. The reason throwing for errors is nice is because it allows you to escape from any point in your code!
Usage
Simply import createError
and throw it at any point. createError will create a boom error resulting in a pretty JSON output.
This will result in JSON which looks like this:
Error Object
You can also throw a standard JavaScript Error
object with a message
and statusCode
(defaults to 500).
Last updated