Skip to main content

ResponseError

Home > @backstage/errors > ResponseError

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

The server is expected to respond on the ErrorResponseBody format.

Signature:

class ResponseError extends Error 

Extends: Error

Properties

PropertyModifiersTypeDescription
bodyreadonlyErrorResponseBodyThe parsed JSON error body, as sent by the server.
causereadonlyError

The Error cause, as seen by the remote server. This is parsed out of the JSON error body.

This error always has the plain Error constructor, however all serializable enumerable fields on the remote error including its name are preserved. Therefore, if you want to check the error type, use its name property rather than checking typeof or its constructor or prototype.

responsereadonlyConsumedResponse

The actual response, as seen by the client.

Note that the body of this response is always consumed. Its parsed form is in the body field.

statusCodereadonlynumber
statusTextreadonlystring

Methods

MethodModifiersDescription
fromResponse(response)static

Constructs a ResponseError based on a failed response.

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.