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.
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
casebranch below pointing at the matching B2Error subclass. Unknown codes fall through to the HTTP-status-based heuristic and finally to a genericB2Error— that's safe but loses semantic specificity (the caller can'tinstanceofagainst a precise subclass and the retry decision relies on status alone). TheB2ErrorCodeunion insrc/types/errors.tsshould also gain the new code at the same time so the switch is exhaustive again.