import {
AuthenticationError,
NotFoundError,
RateLimitError,
APIConnectionError,
} from '@airstore/sdk'
try {
const ws = await airstore.workspaces.retrieve('ws_abc123')
} catch (err) {
if (err instanceof AuthenticationError) {
// Bad API key -- check AIRSTORE_API_KEY
} else if (err instanceof NotFoundError) {
// Workspace doesn't exist
} else if (err instanceof RateLimitError) {
// Shouldn't normally hit this (auto-retried), but possible if retries exhausted
} else if (err instanceof APIConnectionError) {
// Network issue -- DNS, firewall, etc.
} else {
throw err // unexpected
}
}