@backblaze-labs/b2-sdk - v0.1.0
    Preparing search index...

    Function classifyError

    • Maps a B2 error response to the appropriate B2Error subclass. Uses the error code for exact matching, then falls back to HTTP status codes.

      Maintainer note: when B2 documents a new error code, add a case branch below pointing at the matching B2Error subclass. Unknown codes fall through to the HTTP-status-based heuristic and finally to a generic B2Error — that's safe but loses semantic specificity (the caller can't instanceof against a precise subclass and the retry decision relies on status alone). The B2ErrorCode union in src/types/errors.ts should also gain the new code at the same time so the switch is exhaustive again.

      Parameters

      • response: B2ErrorResponse

        Parsed B2 error response body.

      • Optionaloptions: { requestId?: string; retryAfter?: number }

        Optional retry and request metadata from response headers.

      Returns B2Error

      A typed B2Error subclass instance.