Error handling
Every API call on SwiftSonicClient throws SwiftSonicError on failure. The error type carries enough metadata to decide whether to retry, prompt for credentials, or bubble up.
Classification helpers
Section titled “Classification helpers”TODO: confirm the full set of helpers and the exact error cases in 0.6.x. Verify against
Sources/SwiftSonic/SwiftSonicError.swift.
do { let albums = try await client.getAlbumList2(type: .recent)} catch let error as SwiftSonicError { if error.isAuthenticationFailure { // 401-like: prompt for new credentials } else if error.isTransient { // network blip, will likely recover if let delay = error.suggestedRetryDelay { // server told us when to come back } } else { // non-recoverable: surface to user }}The three documented helpers are:
isAuthenticationFailure— credentials rejected, token-derivation failure, etc.isTransient— should be safe to retry.suggestedRetryDelay— non-nil when the server included aRetry-Afterheader (or equivalent signal).
Pattern matching
Section titled “Pattern matching”TODO: list the concrete
SwiftSonicErrorcases (network, http(status), decoding, server(code), …) once verified in source.
If you have a retry policy configured, transient errors are handled automatically — your catch block will only see them if every retry attempt failed.