Skip to content

Error reference

Overview: unified failure envelope (ErrorEnvelope) contract from src/api/ErrorEnvelope.h.

Error structure

All Bridge failures follow a machine-readable envelope. Successful payloads remain endpoint-specific; failures always include a stable code.

Synchronous API failures

fb2k.invoke() failures return:

json
{
  "success": false,
  "error": "Human-readable error message",
  "code": "MACHINE_READABLE_CODE"
}
  • success — always false
  • error — human-readable message (string)
  • code — machine-readable code (string, UPPER_SNAKE_CASE)

Some handlers also attach a details object:

json
{
  "success": false,
  "error": "Playlist is locked",
  "code": "LOCKED",
  "details": { "playlist": 3, "isLocked": true }
}

Asynchronous failure events

Background or async work may push a failure event payload:

json
{
  "error": "Failed to open decoder",
  "code": "DECODER_FAILED",
  "taskId": "waveform_42",
  "path": "E:\\Music\\song.flac"
}

Framework-level failures

Invalid requests or unknown methods are rejected by BridgeCore before a handler runs:

json
{
  "error": "Method not found: foo.bar",
  "code": "METHOD_NOT_FOUND"
}

Standard error codes (ApiErrorCode)

Framework

CodeMeaning
INVALID_REQUESTRequest is missing the method field
METHOD_NOT_FOUNDThe method name is not registered
INTERNAL_ERRORHandler threw an uncaught exception

Parameter errors

CodeMeaning
REQUIRED_PARAMA required parameter is missing
INVALID_PARAMSA parameter value is invalid
INVALID_INDEXAn index is out of range

State / resource errors

CodeMeaning
NOT_FOUNDResource does not exist
LOCKEDPlaylist or resource is locked
NOT_SUPPORTEDOperation is unsupported in the current mode
LIBRARY_DISABLEDMedia library is disabled
NO_ACTIVE_ITEMNo active playlist or now-playing item

Operation failures

CodeMeaning
OPERATION_FAILEDGeneric operation failure

Security

CodeMeaning
PERMISSION_DENIEDPath security policy rejected the request

Media / path

CodeMeaning
MISSING_PATHPath parameter was not provided
INVALID_PATHPath is invalid or the file does not exist
INVALID_HANDLEMetadb handle creation failed
NO_INFOTechnical file information is unavailable
DECODER_FAILEDAudio decoder open failed
DECODE_FAILEDDecoding failed
UNKNOWN_ERRORUnknown error
EXCEPTIONCatch-all exception path

TypeScript types

typescript
import type { ErrorEnvelope, FailureEventPayload, ApiErrorCode } from 'sdk/index.d.ts';
  • ErrorEnvelope — minimum synchronous failure shape
  • FailureEventPayload — minimum async failure event data
  • ApiErrorCode — union of standard codes
  • BaseResponse — shared optional error / code fields

Handling examples

javascript
const result = await fb2k.invoke('library.browseTree', { rootId: 'invalid' });
if (!result.success) {
  console.error(`Error [${result.code}]: ${result.error}`);
}

fb2k.on('audio:fullWaveformFailed', (event) => {
  console.error(`Waveform failed [${event.code}]: ${event.error}`);
  console.error(`taskId=${event.taskId} path=${event.path}`);
});

fb2k.on('http:response', (data) => {
  if (data.error) {
    console.error(`HTTP ${data.requestId} failed [${data.code}]: ${data.error}`);
  }
});

Compatibility notes

  • Existing { success: false, error: string } responses remain valid.
  • code is additive; consumers should treat it as optional when reading older payloads.
  • Artwork endpoints keep their dedicated availability fields.
  • Framework SendError responses include code while preserving error.