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 |
Example
throw new APIError(400, "Invalid email/password", ["email", "password"]);
throw new APIError(400, "Missing auth token.", null, { withStack: false });