Reusable API errors.
- Source:
Classes
Methods
(static) forbidden(codeopt, messageopt) → {ApiError}
- Source:
Returns an HTTP 403 Forbidden error.
The message defaults to "You are not authorized to access this resource. Authenticate with a user account that has more privileges.".
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
code |
string |
<optional> |
auth.forbidden
|
A code identifying the error. |
message |
string |
<optional> |
A description of the problem. |
Returns:
An API error.
- Type
- ApiError
(static) invalidAuthorization() → {ApiError}
- Source:
Returns an HTTP 401 Unauthorized error with the auth.invalidAuthorization
code due to invalid credentials (e.g. an expired JWT).
Returns:
An API error.
- Type
- ApiError
(static) malformedAuthorization() → {ApiError}
- Source:
Returns an HTTP 401 Unauthorized error with the auth.malformedAuthorization
code due to malformed credentials (e.g. a badly formatted Authorization header).
Returns:
An API error.
- Type
- ApiError
(static) missingAuthorization() → {ApiError}
- Source:
Returns an HTTP 401 Unauthorized error with the auth.missingAuthorization
code due to missing credentials.
Returns:
An API error.
- Type
- ApiError
(static) notFound(codeopt, messageopt) → {ApiError}
- Source:
Returns an HTTP 404 Not Found error.
The message defaults to "No resource was found at this verb and URI.".
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
code |
string |
<optional> |
resource.notFound
|
A code identifying the error. |
message |
string |
<optional> |
A description of the problem. |
Returns:
An API error.
- Type
- ApiError
(static) recordNotFound() → {ApiError}
- Source:
Returns an HTTP 404 Not Found error due to a missing resource.
Returns:
An API error.
- Type
- ApiError
(static) unauthorized(code, message) → {ApiError}
- Source:
Returns an HTTP 401 Unauthorized error.
Parameters:
Name | Type | Description |
---|---|---|
code |
string | A code identifying the error (e.g. |
message |
string | A description of the problem. |
Returns:
An API error.
- Type
- ApiError