Skip to main content

@backstage/errors

Home > @backstage/errors

Common utilities for error handling within Backstage

Classes

ClassDescription
AuthenticationErrorThe request requires authentication, which was not properly supplied.
ConflictErrorThe request could not complete due to a conflict in the current state of the resource.
CustomErrorBaseA base class that custom Error classes can inherit from.
ForwardedError

An error that forwards an underlying cause with additional context in the message.

The name property of the error will be inherited from the cause if possible, and will otherwise be set to 'Error'.

InputErrorThe given inputs are malformed and cannot be processed.
NotAllowedErrorThe authenticated caller is not allowed to perform this request.
NotFoundError

The requested resource could not be found.

Note that this error usually is used to indicate that an entity with a given ID does not exist, rather than signalling that an entire route is missing.

NotImplementedErrorThe server does not support the functionality required to fulfill the request.
NotModifiedErrorThe requested resource has not changed since last request.
ResponseError

An error thrown as the result of a failed server request.

The server is expected to respond on the ErrorResponseBody format.

ServiceUnavailableErrorThe server is not ready to handle the request.

Functions

FunctionDescription
assertError(value)

Asserts that an unknown value is an ErrorLike object, which guarantees that it's an object that has at least two string properties: a non-empty name and message.

If the value is not an ErrorLike object, an error is thrown.

deserializeError(data)Deserializes a serialized error object back to an Error.
isError(value)Checks whether an unknown value is an ErrorLike object, which guarantees that it's an object that has at least two string properties: a non-empty name and message.
parseErrorResponseBody(response)

Attempts to construct an ErrorResponseBody out of a failed server request. Assumes that the response has already been checked to be not ok. This function consumes the body of the response, and assumes that it hasn't been consumed before.

The code is forgiving, and constructs a useful synthetic body as best it can if the response body wasn't on the expected form.

serializeError(error, options)Serializes an error object to a JSON friendly form.
stringifyError(error)Stringifies an error, including its name and message where available.

Type Aliases

Type AliasDescription
ConsumedResponseConsumedResponse represents a Response that is known to have been consumed. The methods and properties used to read the body contents are therefore omitted.
ErrorLikeAn object that is shaped like an Error.
ErrorResponseBodyA standard shape of JSON data returned as the body of backend errors.
SerializedErrorThe serialized form of an Error.