@kernel/exceptions
Last updated
Was this helpful?
Last updated
Was this helpful?
Common error classes
Suite of node.js Error classes like most other modern languages
Generate your own custom Error classes
Map HTTP status codes to Errors for automatic handling responses from web services and applications
Suitable to run on browsers (client-side)
npm install @kernel/exceptions
AlreadyInUseError
ArgumentError
ArgumentNullError
AuthenticationRequiredError
ConnectionError
DataError
ForbiddenError
HttpError
InvalidOperationError
SocketError
NotFoundError
NotImplementedError
NotPermittedError
NotSupportedError
RangeError
ReferenceError
SyntaxError
TimeoutError
TypeError
URIError
Applicable when a resource is already in use, for example unique key constraints like a username.
Arguments
entityName
- the entity that owns the protected resource
args
- the fields or attributes that are already in use
error
- the Error instance that caused the current error. Stack trace will be appended
Applicable when there's a generic problem with an argument received by a function call.
Arguments
argumentName
- the name of the argument that has a problem
error
- the Error instance that caused the current error. Stack trace will be appended
Applicable when an argument received by a function call is null/undefined or empty.
Arguments
message
- any message
code
- the error code
error
- the Error instance that caused the current error. Stack trace will be appended
Applicable when an operation requires authentication
Arguments
message
- any message
code
- the error code
error
- the Error instance that caused the current error. Stack trace will be appended
Applicable when an error occurs on a connection.
Arguments
message
- any message
code
- the error code
error
- the Error instance that caused the current error. Stack trace will be appended
Applicable when an error occurs on or with an external data source.
Arguments
message
- any message
code
- the error code
error
- the Error instance that caused the current error. Stack trace will be appended
Applicable when an operation is not permitted
Arguments
message
- any message
code
- the error code
error
- the Error instance that caused the current error. Stack trace will be appended
Represents a message and a HTTP status code.
Arguments
code
- any HTTP status code integer
message
- any message
codeMap
- the mapping of error codes and their classes
error
- the Error instance that caused the current error. Stack trace will be appended
Applicable when an invalid operation occurs.
Arguments
message
- any message
code
- the error code
error
- the Error instance that caused the current error. Stack trace will be appended
Applicable when an attempt to retrieve data yielded no result.
Arguments
entity_name
- a description for what was not found
code
- the error code
error
- the Error instance that caused the current error. Stack trace will be appended
Applicable when a requested method or operation is not implemented.
Arguments
message
- any message
code
- the error code
error
- the Error instance that caused the current error. Stack trace will be appended
Applicable when a certain condition is not supported by your application.
Arguments
message
- a message
code
- the error code
error
- the Error instance that caused the current error. Stack trace will be appended
Represents an error that occurs when a numeric variable or parameter is outside of its valid range. This is roughly the same as the native RangeError class. It additionally supports an code attribute.
Arguments
message
- a message
code
- the error code
error
- the Error instance that caused the current error. Stack trace will be appended
Represents an error when a non-existent variable is referenced. This is roughly the same as the native ReferenceError class. It additionally supports an code attribute.
Arguments
message
- a message
code
- the error code
error
- the Error instance that caused the current error. Stack trace will be appended
Applicable when an error occurs on a socket.
Arguments
message
- any message
code
- the error code
error
- the Error instance that caused the current error. Stack trace will be appended
Represents an error when trying to interpret syntactically invalid code. This is roughly the same as the native SyntaxError class. It additionally supports an code attribute.
Arguments
message
- a message
code
- the error code
error
- the Error instance that caused the current error. Stack trace will be appended
Applicable when an operation takes longer than the alloted amount.
Arguments
time
- a time duration
code
- the error code
error
- the Error instance that caused the current error. Stack trace will be appended
Represents an error when a value is not of the expected type. This is roughly the same as the native TypeError class. It additionally supports an code attribute.
Arguments
message
- a message
code
- the error code
error
- the Error instance that caused the current error. Stack trace will be appended
Represents an error when a value is not of the expected type. This is roughly the same as the native URIError class. It additionally supports an code attribute.
Arguments
message
- a message
code
- the error code
error
- the Error instance that caused the current error. Stack trace will be appended