Skip to content

tojson errorhandler

jarnoux edited this page Jun 23, 2013 · 4 revisions

Description

This middleware is an error handler middleware that outputs an error to the response with an appropriate html status code. The response is a JSON plain text string that has the following format

{
    "type": "MyError", # the error constructor name
    "status": 404, # the HTTP status generated for that type
    "message": "This is my Error" # the error message
}

Configuration

Example

"tojson-errorhandler": {
    "statuses": {
        "MongoError": 409,
        "InvalidCredentialsError": 401
    }
}

Members

statuses. This member maps errors constructor names to an http status to send along the response

Clone this wiki locally