@kernel/exceptions
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)
Install
npm install @kernel/exceptions
Class Directory
Common Error Classes
AlreadyInUseError
ArgumentError
ArgumentNullError
AuthenticationRequiredError
ConnectionError
DataError
ForbiddenError
HttpError
InvalidOperationError
SocketError
NotFoundError
NotImplementedError
NotPermittedError
NotSupportedError
RangeError
ReferenceError
SyntaxError
TimeoutError
TypeError
URIError
Error Classes
AlreadyInUseError
Applicable when a resource is already in use, for example unique key constraints like a username.
Arguments
entityName- the entity that owns the protected resourceargs- the fields or attributes that are already in useerror- the Error instance that caused the current error. Stack trace will be appended
ArgumentError
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 problemerror- the Error instance that caused the current error. Stack trace will be appended
ArgumentNullError
Applicable when an argument received by a function call is null/undefined or empty.
Arguments
message- any messagecode- the error codeerror- the Error instance that caused the current error. Stack trace will be appended
AuthenticationRequiredError
Applicable when an operation requires authentication
Arguments
message- any messagecode- the error codeerror- the Error instance that caused the current error. Stack trace will be appended
ConnectionError
Applicable when an error occurs on a connection.
Arguments
message- any messagecode- the error codeerror- the Error instance that caused the current error. Stack trace will be appended
DataError
Applicable when an error occurs on or with an external data source.
Arguments
message- any messagecode- the error codeerror- the Error instance that caused the current error. Stack trace will be appended
ForbiddenError
Applicable when an operation is not permitted
Arguments
message- any messagecode- the error codeerror- the Error instance that caused the current error. Stack trace will be appended
HttpError
Represents a message and a HTTP status code.
Arguments
code- any HTTP status code integermessage- any messagecodeMap- the mapping of error codes and their classeserror- the Error instance that caused the current error. Stack trace will be appended
InvalidOperationError
Applicable when an invalid operation occurs.
Arguments
message- any messagecode- the error codeerror- the Error instance that caused the current error. Stack trace will be appended
NotFoundError
Applicable when an attempt to retrieve data yielded no result.
Arguments
entity_name- a description for what was not foundcode- the error codeerror- the Error instance that caused the current error. Stack trace will be appended
NotImplementedError
Applicable when a requested method or operation is not implemented.
Arguments
message- any messagecode- the error codeerror- the Error instance that caused the current error. Stack trace will be appended
NotSupportedError
Applicable when a certain condition is not supported by your application.
Arguments
message- a messagecode- the error codeerror- the Error instance that caused the current error. Stack trace will be appended
RangeError
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 messagecode- the error codeerror- the Error instance that caused the current error. Stack trace will be appended
ReferenceError
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 messagecode- the error codeerror- the Error instance that caused the current error. Stack trace will be appended
SocketError
Applicable when an error occurs on a socket.
Arguments
message- any messagecode- the error codeerror- the Error instance that caused the current error. Stack trace will be appended
SyntaxError
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 messagecode- the error codeerror- the Error instance that caused the current error. Stack trace will be appended
TimeoutError
Applicable when an operation takes longer than the alloted amount.
Arguments
time- a time durationcode- the error codeerror- the Error instance that caused the current error. Stack trace will be appended
TypeError
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 messagecode- the error codeerror- the Error instance that caused the current error. Stack trace will be appended
URIError
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 messagecode- the error codeerror- the Error instance that caused the current error. Stack trace will be appended
Last updated
Was this helpful?