Convention: B2Error and its subclasses represent failures returned by
the B2 API. Programming errors and SDK preconditions (e.g. "not yet
authorized", "stream consumed twice", "called before init") use the
native Error constructor instead. Two outliers extend Error directly
rather than B2Error because they originate inside the SDK before any
B2 request is made: B2InsufficientCapabilityError (raised by
B2Client.hasCapabilities) and B2SsrfError (raised by the
default UrlGuard before fetch).
Typed error hierarchy for B2 API failures.
Every B2 error response is mapped to a specific B2Error subclass (e.g. ExpiredAuthTokenError, CapExceededError) with pre-computed retryable flags. Use classifyError to convert a raw error response into the appropriate subclass.
Convention:
B2Errorand its subclasses represent failures returned by the B2 API. Programming errors and SDK preconditions (e.g. "not yet authorized", "stream consumed twice", "called before init") use the nativeErrorconstructor instead. Two outliers extendErrordirectly rather thanB2Errorbecause they originate inside the SDK before any B2 request is made: B2InsufficientCapabilityError (raised byB2Client.hasCapabilities) and B2SsrfError (raised by the defaultUrlGuardbeforefetch).