Skip to content
API/QubeeFetchError

QubeeFetchError

error
src/errors/qubee-fetch.error.ts

Thrown by fetchQubeePage — and reported by the hooks built on it — when the API answers with a status that is not ok.

It carries the response, so the caller can read the body the API sent with the failure. It extends Error rather than core’s QubeeError, whose code is a closed union owned by @qubeejs/core. Object.setPrototypeOf keeps instanceof working when a consumer’s toolchain downlevels classes below ES2015.

Extends Error.

import { QubeeFetchError } from '@qubeejs/react';
import { QubeeFetchError } from '@qubeejs/react/fetch';

The entries export the same thing: import it from whichever the file already uses.

new QubeeFetchError(uri: string, response: Response)
Parameter Type Description
uri string The address that was requested
response Response The response the fetcher returned
Property Type Description
response Response The response as the fetcher returned it; its body has not been read.
status number The HTTP status of the response, e.g. 404.
uri string The address that was requested.
if (error instanceof QubeeFetchError && error.status === 401) {
redirectToLogin();
}