Skip to main content

Class: AssetFetchError

Defined in: src/core/errors.ts:284

The fetch failed (403, 429, 5xx, network, exhausted retries) — the answer is unknown.

Example​

import sdv, { AssetFetchError, NoDataError } from 'sportsdataverse';

try {
await sdv.nfl.espnNflSummary({ event: 401671789 });
} catch (err) {
if (err instanceof NoDataError) return [];
if (err instanceof AssetFetchError) console.error(err.status, err.url, err.cause); // surface it
throw err;
}

Remarks​

Also what request() throws for a failing auth step ("<family>: auth failed (apply)"), an empty 2xx body, or a JSON request whose 2xx body is not JSON. Never record one as an empty season: a failed fetch is not "no data" (NoDataError).

Extends​

Constructors​

Constructor​

new AssetFetchError(message, details): AssetFetchError

Defined in: src/core/errors.ts:293

Parameters​

message​

string

Message naming the family, host / path and status, already redacted.

details​

FetchErrorDetails

url (query-free), optional status and cause (FetchErrorDetails).

Returns​

AssetFetchError

Overrides​

SdvError.constructor

Properties​

status?​

readonly optional status?: number

Defined in: src/core/errors.ts:288

HTTP status of the final response; absent when no response arrived (network error).


url​

readonly url: string

Defined in: src/core/errors.ts:286

Request URL, without the query string.