Result<T, E> rather than throwing exceptions.
Result Pattern
Error Types
All errors have a_tag property for type discrimination.
NetworkError
Connection failures, timeouts, and aborted requests.| Field | Type | Description |
|---|---|---|
code | NetworkErrorCode | TIMEOUT, CONNECTION_FAILED, DNS_FAILED, SSL_ERROR, ABORTED, OFFLINE |
message | string | Human-readable description |
retryable | boolean | Whether the request can be retried |
retryAfterMs | number? | Suggested retry delay in milliseconds |
ApiError
Server errors, rate limits, and GraphQL errors.| Field | Type | Description |
|---|---|---|
code | ApiErrorCode | NOT_FOUND, RATE_LIMITED, GRAPHQL_ERROR, etc. |
source | ApiSource | 'layers' or 'storefront' |
status | number? | HTTP status code |
retryable | boolean | Whether the request can be retried |
retryAfterMs | number? | Suggested retry delay |
ValidationError
Invalid parameters passed to SDK methods.| Field | Type | Description |
|---|---|---|
operation | string | Which method failed (e.g. 'search') |
fields | ValidationFieldError[] | [{ field, code, message }] |
ConfigError
SDK configuration issues at init time.| Field | Type | Description |
|---|---|---|
field | string | Which config field is wrong |
expected | string? | What was expected |