Skip to main content
Version: Next

parseErrorResponseBody()

Home > @backstage/errors > parseErrorResponseBody

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.

Signature:

function parseErrorResponseBody(response: ConsumedResponse & {
text(): Promise<string>;
}): Promise<ErrorResponseBody>;

Parameters

Parameter

Type

Description

response

ConsumedResponse & { text(): Promise<string>; }

The response of a failed request

**Returns:**

Promise<ErrorResponseBody>