Skip to main content

Function: toPlayerError()

function toPlayerError(thrown: unknown, uri?: string): PlayerError;

Defined in: packages/player/src/errors.ts:422

Map anything thrown by the native MpvClient (or by this library) onto the typed PlayerError taxonomy.

Native tags every message it throws — [mpv:disposed], [mpv:invalid-state], [mpv:unsupported], [mpv:<errno>] (see docs/specs/player-core.md §2.5) — and this function is the only place that knows those tags.

Parameters

ParameterTypeDescription
thrownunknownThe value caught from a native call or a rejected promise.
uri?stringThe source URI in play at the time, if any. Used to tell a network failure apart from a local load failure.

Returns

PlayerError

A typed error; never throws, never returns undefined.