@backblaze-labs/b2-mcp
    Preparing search index...

    Function parseB2Error

    • Parse an error from a B2 API call and return a structured error object.

      Handles the error shapes used in this codebase:

      • B2 SDK typed/native errors: err.status + err.code + err.requestId
      • S3 / AWS SDK v3: err.$metadata.httpStatusCode + err.name/err.Code, with the trace id in err.$metadata.requestId.
      • Legacy HTTP-client response errors retained for compatibility in tests.
      • Local TimeoutError maps to request_timeout / HTTP 504.
      • Local AbortError maps to request_aborted / HTTP 499.
      • Coded errors wrapped in .cause, including operation_status_unknown / HTTP 409 from interrupted no-replay native B2 writes.

      Reading the AWS SDK shape is what lets us tell a genuine Backblaze 5xx apart from a 4xx (e.g. NoSuchKey) and surface the requestId support needs.

      Parameters

      • err: unknown

        Error value thrown by B2 native, S3-compatible, or local code.

      Returns B2ApiError

      The normalized B2 API error object.