Skip to content

Errors

The SDK rejects with an OpenpickerError that carries a stable code (and a human-readable message, plus optional data). Branch on code, not the message.

ts
import { OpenpickerError } from "@openpicker/sdk"

try {
  await op.pick({ url: "https://app.example.com" })
} catch (err) {
  if (err instanceof OpenpickerError) {
    switch (err.code) {
      case "cancelled":
        // the user closed/cancelled the picker
        break
      case "consent_denied":
        // this origin isn't allowed (see Authorization)
        break
      case "extension_not_installed":
        // prompt the user to install openpicker
        break
      default:
        // surface err.message
    }
  }
}

Codes

CodeMeaning
extension_not_installedThe SDK got no response to ping within the timeout.
unsupported_protocolNo overlapping protocol version between the SDK and the extension.
consent_deniedThe origin isn't allowed (denied in Ask, or blocked in Blocklist).
cancelledThe user cancelled or closed the picker.
invalid_paramsMalformed params for the method (e.g. pick without a url).
unsupportedThe method/option isn't supported by this extension.
timeoutSDK-side: no response within the timeout.
internal_errorUnexpected extension failure.

Tip

Call isAvailable() (a wrapped ping) before showing a "pick" affordance, so you can guide the user to install the extension instead of letting pick fail later.

Released under the MIT License.