Skip to content

EZ Web Audio / AudioError

Class: AudioError

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

Base error class for all audio-related errors.

Provides a consistent error structure with optional error codes for programmatic error handling. Subclasses add specific context like URL, note identifier, or AudioContext state.

Example

typescript
import { AudioError } from 'ez-web-audio'

try {
  await sound.play()
} catch (e) {
  if (e instanceof AudioError) {
    console.error(`Audio error [${e.code}]: ${e.message}`)
  }
}

Extends

  • Error

Extended by

Constructors

Constructor

new AudioError(message, code?): AudioError

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

Create a new AudioError.

Parameters

message

string

Human-readable error description with actionable fix

code?

string

Optional error code for programmatic handling

Returns

AudioError

Overrides

Error.constructor

Properties

code?

readonly optional code: string

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

Optional error code for programmatic handling