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

    Function classifyError

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

      Maintainer note: when B2 documents a new error code, add it to KNOWN_B2_ERROR_CODES in src/types/errors.ts and add a matching classifyKnownError switch case. Unknown codes fall through to the HTTP-status-based heuristic and finally to a generic B2Error, which is safe but loses semantic specificity (the caller can't instanceof against a precise subclass and the retry decision relies on status alone).

      Parameters

      • response: B2ErrorResponse

        Parsed B2 error response body.

      • Optionaloptions: B2ErrorOptions

        Optional retry and request metadata from response headers.

      Returns B2Error

      A typed B2Error subclass instance.