Skip to main content
Breaking in 4.0.0
  • Integer id columns are decimal strings — Every id column of integers (id, *_id, game_pk, playerId, …) comes back as exact decimal strings on every surface — parsers, producers, loaders, HockeyTech analytics. Compare and join ids as strings; Number(row.game_id) for a safe number back. (changelog)
  • 400 / 422 raise InvalidParameterError — For every family (it was AssetFetchError), never retried; the message names host, path and status with a redacted excerpt of the body. (changelog)
  • Typed returns — generated row types for parsed: true — TypeScript only. A wrapper's raw payload resolves to unknown (was any); verified endpoints resolve to their row interfaces; the summary dispatchers to ParsedTables. Narrow or cast a raw payload. (changelog)
  • Wrapper failures raise NoDataError / AssetFetchError — Instead of raw axios errors. NoDataError = the fetch worked and there is nothing there (404, ESPN { code: 404 }); AssetFetchError = the fetch failed (403 / 429 / 5xx after retries, network). Retries follow DEFAULT_RETRY_STATUSES with backoff. (changelog)

Errors

Not data functions

These utilities never fetch a provider payload by themselves — they transform, classify, configure or look things up. The data surface (every espn* / native wrapper and load* loader) is under ESPN Reference.

The error vocabulary — NoDataError (nothing there) is never AssetFetchError (the fetch failed).

Exportkindmodule
SdvErrorclasssrc/core/errors.ts
NoDataErrorclasssrc/core/errors.ts
AssetFetchErrorclasssrc/core/errors.ts
InvalidParameterErrorclasssrc/core/errors.ts
SeasonNotFoundErrorclasssrc/core/errors.ts
TransportUnavailableErrorclasssrc/core/errors.ts
NoESPNDataErrorclasssrc/core/errors.ts
FetchErrorDetailstypesrc/core/errors.ts

src/core/errors.ts​

The error vocabulary. NoDataError means the fetch worked and nothing is there (404, ESPN's \{ code: 404 \}); AssetFetchError means the fetch failed and the answer is unknown (403 / 429 / 5xx after retries, a network error, an empty or non-JSON 2xx). They are never collapsed.

Import: import { … } from 'sportsdataverse'

SdvError​

Base class of every error the package raises; cause is always redacted.

export class SdvError extends Error

NoDataError​

The fetch succeeded and there is nothing there (HTTP 404, ESPN \{ code: 404 \}).

export class NoDataError extends SdvError

Example:

try { await sdv.nba.espnNbaSummary({ event_id: 1 }); }
catch (e) { if (e instanceof NoDataError) console.log('no such game'); else throw e; }

AssetFetchError​

The fetch failed (403 / 429 / 5xx after retries, network, an unusable 2xx body); carries status, url, cause.

export class AssetFetchError extends SdvError

InvalidParameterError​

The server rejected the request's parameters (HTTP 400 / 422); never retried.

export class InvalidParameterError extends SdvError

SeasonNotFoundError​

A season below a loader's floor, raised before anything is fetched.

export class SeasonNotFoundError extends SdvError {}

TransportUnavailableError​

An optional transport dependency (impit) is not installed.

export class TransportUnavailableError extends SdvError {}

NoESPNDataError​

Back-compat alias of NoDataError (the error was ESPN-only when it was named).

export const NoESPNDataError

FetchErrorDetails​

The status / url / cause an AssetFetchError carries.

export interface FetchErrorDetails

Generated by tools/codegen/generate.mjs from tools/codegen/utilities.yaml — see How this library is built.