Skip to content

EZ Web Audio / AudioContextError

Class: AudioContextError

Defined in: errors/context-error.ts:20

Error thrown when AudioContext is in an invalid state.

Common causes:

  • AudioContext suspended (not yet resumed after user interaction)
  • AudioContext closed

Example

typescript
if (audioContext.state === 'suspended') {
  throw new AudioContextError(
    'AudioContext suspended. Call initAudio() after user interaction (click, tap).',
    audioContext.state
  );
}

Extends

Constructors

Constructor

new AudioContextError(message, state): AudioContextError

Defined in: errors/context-error.ts:27

Create a new AudioContextError.

Parameters

message

string

Human-readable error description with actionable fix

state

AudioContextState

The current AudioContext state when the error occurred

Returns

AudioContextError

Overrides

AudioError.constructor

Properties

code?

readonly optional code: string

Defined in: errors/audio-error.ts:30

Optional error code for programmatic handling

Inherited from

AudioError.code


state

readonly state: AudioContextState

Defined in: errors/context-error.ts:29

The current AudioContext state when the error occurred