Class

module:APIError

module:APIError(code, message, fieldsopt, optionsopt)

Constructor

# new module:APIError(code, message, fieldsopt, optionsopt)

APIError is used to pass errors from anywhere in the express call stack to the error handling middleware.

Parameters:
Name Type Attributes Description
code Number

The HTTP code of the error

message string

The error message

fields string | Array.<string> | null <optional>

Fields (query parameters) related to the error

options Object <optional>

Options

View Source global/APIError.js, line 23

Example
throw new APIError(400, "Invalid email/password", ["email", "password"]);
throw new APIError(400, "Missing auth token.", null, { withStack: false });