onError

Receive Bluetooth runtime and device measurement failures.

  • Stable unknown
  • Release candidate since 1.16.1-rc.3
  • Development since 1.16.1-dev.2111+9796905

onError receives errors reported by discovery, connection, parsing, and background-delivery paths. The payload can include deviceData, a normalized error code, and an Error, string, or Bluetooth error value.

<BTProvider
  {...providerProps}
  onError={({ deviceData, error, code }) => {
    reportBluetoothIssue({
      deviceName: deviceData?.name,
      code,
      message: error instanceof Error ? error.message : String(error),
    });
  }}
/>

Use the optional code for stable programmatic handling. Use the supplied message for diagnostics, not as a user-facing promise: native errors can vary by platform and OS version. For user copy, map known error codes to app-owned messages and provide a retry or settings action where appropriate.

See Bluetooth error types for the public error shape.

Last updated on