API/QubeeFetchError
QubeeFetchError
errorsrc/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
Section titled “Import”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.
Constructor
Section titled “Constructor”new QubeeFetchError(uri: string, response: Response)Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
uri |
string |
The address that was requested |
response |
Response |
The response the fetcher returned |
Properties
Section titled “Properties”| 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. |
Example
Section titled “Example”if (error instanceof QubeeFetchError && error.status === 401) { redirectToLogin();}