errors-node
v1.0.1
Published
Common errors for your Node.js app. These errors are designed to be used in any layer of the app.
Downloads
4
Readme
Common Errors for Node.js
Common errors for your Node.js app. These errors are designed to be used in any layer of the app.
Usage
Simply reference this module in the dependencies
key of your package.json
file...
"errors": "[email protected]:cybric/errors-node.git"
...and go to town...
const errors = require('errors');
const dataz = require('dataz');
const getMehDataz = (id) => {
dataz.get(id)
.then((item) => {
if (item) return item;
throw new errors.NotFoundError();
});
}
API
TLDR: you use the errors in this library like you would any JavaScript error.
FormatError
Represents a request with an invalid format.
Properties
message
: a description of the error.data
: if provided at construction time, an object containing additional information about the error.defaultMessage
: (static) the default message used if one is not supplied to the constructor.
Methods
constructor
- Parameters
message
: (optional) the string value to use for the message.data
: (optional) additional data to include with the error.
- Parameters
ValidationError
Thrown when an argument is properly formed, but contains invalid information.
Properties
message
: a description of the error.data
: if provided at construction time, an object containing additional information about the error.defaultMessage
: (static) the default message used if one is not supplied to the constructor.
Methods
constructor
- Parameters
message
: (optional) the string value to use for the message.data
: (optional) additional data to include with the error.
- Parameters
CredentialsError
Thrown when authentication credentials or an identity token is invalid.
Properties
message
: a description of the error.data
: if provided at construction time, an object containing additional information about the error.defaultMessage
: (static) the default message used if one is not supplied to the constructor.
Methods
constructor
- Parameters
message
: (optional) the string value to use for the message.data
: (optional) additional data to include with the error.
- Parameters
UnauthorizedError
Thrown when an authenticated user does not have sufficient permissions to perform an operation.
Properties
message
: a description of the error.data
: if provided at construction time, an object containing additional information about the error.defaultMessage
: (static) the default message used if one is not supplied to the constructor.
Methods
constructor
- Parameters
message
: (optional) the string value to use for the message.data
: (optional) additional data to include with the error.
- Parameters
NotFoundError
Thrown when a requested resource does not exist.
Properties
message
: a description of the error.data
: if provided at construction time, an object containing additional information about the error.defaultMessage
: (static) the default message used if one is not supplied to the constructor.
Methods
constructor
- Parameters
message
: (optional) the string value to use for the message.data
: (optional) additional data to include with the error.
- Parameters
ConcurrencyError
Thrown when a provided resource version value (etag) does not match the current version value.
Properties
message
: a description of the error.data
: if provided at construction time, an object containing additional information about the error.defaultMessage
: (static) the default message used if one is not supplied to the constructor.
Methods
constructor
- Parameters
message
: (optional) the string value to use for the message.data
: (optional) additional data to include with the error.
- Parameters
TempUnavailableError
Thrown when a service is temporarily unavailable. If this error is encountered, a retry should be attempted.
Properties
message
: a description of the error.data
: if provided at construction time, an object containing additional information about the error.defaultMessage
: (static) the default message used if one is not supplied to the constructor.
Methods
constructor
- Parameters
message
: (optional) the string value to use for the message.data
: (optional) additional data to include with the error.
- Parameters