Skip to main content
Version: Next

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

Property

Modifiers

Type

Description

body

readonly

ErrorResponseBody

The parsed JSON error body, as sent by the server.

cause

readonly

Error

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.

response

readonly

ConsumedResponse

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.

statusCode

readonly

number

statusText

readonly

string

Methods

Method

Modifiers

Description

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.