Complete error hierarchy for @offerhub/sdk — the base OfferHubError class, every typed subclass, how each maps to an Orchestrator server error code, and the retry semantics that govern automatic backoff.
Every failure raised by @offerhub/sdk extends the base OfferHubError. Catching a specific subclass lets you branch on business failures (InsufficientFundsError) versus infrastructure failures (ProviderError) versus developer mistakes (ValidationError).
Class hierarchy
Mermaid
Rendering diagram…
Base class: OfferHubError
Documentation table
Member
Type
Description
message
string
Human-readable description returned by the API.
code
string
Machine code from the Orchestrator catalog (VALIDATION_ERROR, INSUFFICIENT_FUNDS, …).
statusCode
number
HTTP status of the response, or 0 for network-level failures.
Named SDK subclasses map to the Orchestrator HTTP statuses and server codes below. When a response has no dedicated subclass, handle it through the base OfferHubError. Codes come from docs/api/errors.md in the Orchestrator repo; the status mapping matches the JSON error envelope documented in docs/ai-context.md.
Documentation table
SDK class
HTTP
Server codes
When it fires
Retry?
AuthenticationError
401
UNAUTHORIZED
Missing or invalid API key.
No
AuthorizationError
403
INSUFFICIENT_SCOPE
Valid key, but lacks the required scope for this route.
Automatic retries are handled inside the SDK and governed by retryAttempts (default 3) on OfferHubSDKConfig. Retryable classes use exponential backoff; the exact schedule is an implementation detail but never exceeds timeout per attempt.
Documentation table
Class
Auto-retried
Why
NetworkError
Yes
The connection may succeed next time.
ProviderError
Yes
Upstream provider is the flaky layer.
RateLimitError
Yes
Backoff eventually clears the bucket.
AuthenticationError
No
Wrong key, retrying cannot help.
AuthorizationError
No
Wrong scope, retrying cannot help.
NotFoundError
No
Resource does not exist.
ValidationError
No
Payload is wrong.
InsufficientFundsError
No
Business state.
InvalidTransitionError
No
State machine rejected it.
IdempotencyError
No
Developer mistake.
To disable retries entirely for a specific call, construct a client with retryAttempts: 0:
typescript
const strict = new OfferHubSDK({ apiKey: process.env.OFFERHUB_API_KEY!, retryAttempts: 0,});await strict.orders.reserve("ord_123");
Error envelope
Every SDK exception is a projection of the Orchestrator's JSON error envelope:
json
{ "error": { "code": "INSUFFICIENT_FUNDS", "message": "Available balance 40.00 is less than required 100.00", "details": { "required": "100.00", "available": "40.00" } }}
The SDK lifts code, message, and details onto the thrown instance and classifies the exception by matching the HTTP status and code against the table above. See docs/api/errors.md in the Orchestrator repo for the full server-side catalog.
Related
Troubleshooting & FAQ — symptom-cause-fix recipes for every error above, with Orchestrator source citations.
API Error Codes — Complete 40+ Orchestrator server error code catalog and resolution guide.
Configuration — OfferHubSDKConfig, withIdempotencyKey, and retry policy.