Skip to content

Error reference ​

Overview: the unified ErrorEnvelope failure contract shared by every API.

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"
}

Timeouts ​

fb2k.invoke() waits up to 30 seconds for a response, then rejects with an Error whose code is TIMEOUT. The host may still be executing the operation or may have already completed it; late responses are dropped, so callers should treat the outcome as unknown. See operation results.

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. No method currently returns it: a missing parameter fails with INVALID_PARAMS and the message <name> is required
INVALID_PARAMSA parameter value is invalid
INVALID_INDEXAn index is out of range

State / resource errors ​

CodeMeaning
NOT_FOUNDResource does not exist
OPERATION_PENDINGThe media library is still loading
STALE_TARGETTarget version or state is outdated (optimistic concurrency conflict)
LOCKEDPlaylist or resource is locked
NOT_SUPPORTEDThe environment or the data does not support this operation
PANEL_MODE_UNSUPPORTEDCalled from a DUI/CUI panel, but the method needs the standalone main window. Use window.getMode to learn the mode beforehand
LIBRARY_DISABLEDMedia library is disabled
NO_ACTIVE_ITEMNo active playlist or now-playing item, or no ready next entry for jitSession.skip
CONFLICTState conflicts with the session command, or a request ID was reused with another payload or has expired
NOT_OWNERThe calling document does not hold the current JIT session control token

Operation failures ​

CodeMeaning
OPERATION_FAILEDGeneric operation failure
CANCELLEDThe caller cancelled an async task (for example audio.cancelFullWaveform)
TIMEOUTThe page stopped waiting after 30 seconds; the call may still have run. Reported by fb2k.invoke() itself, not by the host

Security ​

CodeMeaning
PERMISSION_DENIEDPath security policy rejected the request. A parameter that fails on shape or type instead of on path policy returns INVALID_PARAMS
ORIGIN_DENIEDThe page's origin is not trusted for this capability. Every call from a page the host does not trust fails with it (see Security reference); dnd.prepareDrag returns it for a page that is not given file paths, and audio:pcmFailed carries it when the page navigated to an untrusted origin while audio.decodePcm was running

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

Specialized error codes for menu command invocation and inter-component port messaging. They were published before the shared codes above and are kept as they are:

CodeMeaning
MENU_ITEM_DISABLEDThe menu command exists but is disabled (menu.runMainMenuCommand)
MENU_MATCH_AMBIGUOUSA command name or path matched several commands; the failure lists them in details.candidates (menu.runMainMenuCommand)
MENU_COMMAND_NOT_FOUNDNo menu command has that name or path (menu.runMainMenuCommand, menu.runContextCommand)
PORT_NOT_FOUNDNo open port has that id (port.disconnect, port.postMessage, port.postMessageTo)
TARGET_NOT_FOUNDThe target port of port.postMessageTo does not exist

TypeScript types ​

typescript
import type { ErrorEnvelope, FailureEventPayload, ApiErrorCode, BaseResponse } from 'foo-webview-sdk';
  • 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 === false) {
  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 ​

  • Synchronous API failure responses consistently provide success: false and a human-readable error description.
  • Machine-readable code fields cover all standard error categories; consumers should branch on code rather than parsing error message strings, and treat code as optional when reading payloads from older hosts.
  • Artwork endpoints provide an additional available boolean field indicating cover image presence.
  • Both framework-level rejections and unhandled handler exceptions are packaged into standard error envelopes.