Error codes
import ApiTable from "../../../../components/docs/ApiTable.astro"; import Callout from "../../../../components/docs/Callout.astro"; Every error thrown by the SDK is an instance of `ArlopassSDKError` (or a subclass). Errors carry structured metadata for programmatic handling. ```tsx import { ArlopassSDKError, ArlopassStateError, ArlopassTransportError, ArlopassTimeoutError, ArlopassProtocolBoundaryError, ArlopassInvalidStateTransitionError, } from "@arlopass/web-sdk"; ``` --- ### Error hierarchy ```text // Error class hierarchy ArlopassSDKError // Base class — all SDK errors extend this ├── ArlopassStateError // Invalid operation for current state ├── ArlopassInvalidStateTransitionError // Illegal state transition ├── ArlopassProtocolBoundaryError // Protocol envelope validation failure ├── ArlopassTransportError // Transport-layer failure (retryable by default) └── ArlopassTimeoutError // Request timed out (retryable by default) ``` ### Error properties All error subclasses inherit these properties from `ArlopassSDKError`. <ApiTable props={[ { name: "message", type: "string", description: "Human-readable error description.", }, { name: "machineCode", type: "SDKMachineCode", description: "Stable machine-readable code for programmatic handling.", }, { name: "reasonCode", type: "ProtocolReasonCode", description: "Normalized reason code from the protocol layer.", }, { name: "retryable", type: "boolean", description: "Whether this error can be retried.", }, { name: "correlationId", type: "string | undefined", description: "Correlation ID from the failed request.", }, { name: "details", type: "Record<string, string | number | boolean | null> | undefined", description: "Additional structured metadata about the error.", }, { name: "cause", type: "Error | undefined", description: "Original error that caused this one.", }, ]} /> --- ### SDK machine codes Codes prefixed with `ARLOPASS_SDK_` originate in the client SDK. <ApiTable props={[ { name: "ARLOPASS_SDK_INVALID_STATE_TRANSITION", type: "SDK", description: "Attempted an illegal state transition (e.g. connect while already connected).", }, { name: "ARLOPASS_SDK_INVALID_STATE_OPERATION", type: "SDK", description: "Operation not valid in the current state (e.g. chat.send while disconnected).", }, { name: "ARLOPASS_SDK_MISSING_PROVIDER_SELECTION", type: "SDK", description: "Chat operation attempted without selecting a provider first.", }, { name: "ARLOPASS_SDK_PROTOCOL_VIOLATION", type: "SDK", description: "Response envelope failed validation.", }, { name: "ARLOPASS_SDK_TRANSPORT_ERROR", type: "SDK", description: "Transport-level failure (network, serialization, etc.).", }, ]} /> --- ### Protocol machine codes Codes prefixed with `ARLOPASS_` or `ARLOPASS_PROTOCOL_` originate in the protocol layer or extension. <ApiTable props={[ { name: "ARLOPASS_AUTH_FAILED", type: "Protocol", description: "Authentication failure (invalid credentials).", }, { name: "ARLOPASS_PERMISSION_DENIED", type: "Protocol", description: "Caller lacks permission for the requested operation.", }, { name: "ARLOPASS_TIMEOUT", type: "Protocol", description: "Request timed out.", }, { name: "ARLOPASS_PROVIDER_UNAVAILABLE", type: "Protocol", description: "Selected provider is offline or unreachable.", }, { name: "ARLOPASS_TRANSIENT_NETWORK", type: "Protocol", description: "Transient network error.", }, { name: "ARLOPASS_POLICY_VIOLATION", type: "Protocol", description: "Request blocked by a policy rule.", }, { name: "ARLOPASS_PROTOCOL_INVALID_ENVELOPE", type: "Protocol", description: "Envelope structure is invalid.", }, { name: "ARLOPASS_PROTOCOL_MISSING_REQUIRED_FIELD", type: "Protocol", description: "A required field is missing from the envelope.", }, { name: "ARLOPASS_PROTOCOL_ENVELOPE_EXPIRED", type: "Protocol", description: "Envelope TTL has expired.", }, { name: "ARLOPASS_PROTOCOL_REPLAY_PRONE_METADATA", type: "Protocol", description: "Envelope metadata suggests a replay attack.", }, { name: "ARLOPASS_PROTOCOL_UNSUPPORTED_VERSION", type: "Protocol", description: "Protocol version not supported.", }, { name: "ARLOPASS_PROTOCOL_UNSUPPORTED_CAPABILITY", type: "Protocol", description: "Requested capability not supported.", }, ]} /> --- ### Reason codes Normalized reason codes provide a human-readable classification. The SDK normalizes aliases (e.g. `"timeout"` → `"transport.timeout"`). <ApiTable props={[ { name: "allow", type: "Success", description: "Operation succeeded." }, { name: "auth.invalid", type: "Auth", description: "Invalid credentials." }, { name: "auth.expired", type: "Auth", description: "Credentials have expired.", }, { name: "permission.denied", type: "Auth", description: "Insufficient permissions.", }, { name: "policy.denied", type: "Policy", description: "Blocked by policy.", }, { name: "provider.unavailable", type: "Provider", description: "Provider is offline or unreachable.", }, { name: "request.invalid", type: "Request", description: "Malformed request.", }, { name: "request.replay_prone", type: "Request", description: "Request metadata suggests a replay.", }, { name: "request.expired", type: "Request", description: "Request envelope has expired.", }, { name: "protocol.unsupported_version", type: "Protocol", description: "Protocol version mismatch.", }, { name: "protocol.unsupported_capability", type: "Protocol", description: "Capability not recognized.", }, { name: "protocol.invalid_envelope", type: "Protocol", description: "Envelope validation failed.", }, { name: "transport.timeout", type: "Transport", description: "Operation timed out.", }, { name: "transport.cancelled", type: "Transport", description: "Operation was cancelled (e.g. AbortSignal).", }, { name: "transport.transient_failure", type: "Transport", description: "Temporary network or transport issue.", }, ]} /> --- ### Retryable vs non-retryable Every error has a `retryable` boolean. Use it to decide whether to surface a retry button or fail permanently. <ApiTable props={[ { name: "ArlopassTransportError", type: "retryable: true", description: "Transport failures are retryable by default.", }, { name: "ArlopassTimeoutError", type: "retryable: true", description: "Timeouts are retryable by default.", }, { name: "ArlopassStateError", type: "retryable: false", description: "State errors indicate logic bugs — not retryable.", }, { name: "ArlopassInvalidStateTransitionError", type: "retryable: false", description: "Invalid transitions are logic bugs — not retryable.", }, { name: "ArlopassProtocolBoundaryError", type: "retryable: false", description: "Protocol violations typically require a code fix.", }, ]} /> ```tsx if (error instanceof ArlopassSDKError && error.retryable) { await retry(); } ``` <Callout type="warning" title="Retryable is a hint"> The `retryable` flag is a default. The extension or adapter may override it based on the specific failure context. </Callout>Every error thrown by the SDK is an instance of ArlopassSDKError (or a subclass). Errors carry structured metadata for programmatic handling.
import {
ArlopassSDKError,
ArlopassStateError,
ArlopassTransportError,
ArlopassTimeoutError,
ArlopassProtocolBoundaryError,
ArlopassInvalidStateTransitionError,
} from "@arlopass/web-sdk";
Error hierarchy
// Error class hierarchy
ArlopassSDKError // Base class — all SDK errors extend this
├── ArlopassStateError // Invalid operation for current state
├── ArlopassInvalidStateTransitionError // Illegal state transition
├── ArlopassProtocolBoundaryError // Protocol envelope validation failure
├── ArlopassTransportError // Transport-layer failure (retryable by default)
└── ArlopassTimeoutError // Request timed out (retryable by default)
Error properties
All error subclasses inherit these properties from ArlopassSDKError.
| Prop | Type | Default | Description |
|---|---|---|---|
message | string | — | Human-readable error description. |
machineCode | SDKMachineCode | — | Stable machine-readable code for programmatic handling. |
reasonCode | ProtocolReasonCode | — | Normalized reason code from the protocol layer. |
retryable | boolean | — | Whether this error can be retried. |
correlationId | string | undefined | — | Correlation ID from the failed request. |
details | Record<string, string | number | boolean | null> | undefined | — | Additional structured metadata about the error. |
cause | Error | undefined | — | Original error that caused this one. |
SDK machine codes
Codes prefixed with ARLOPASS_SDK_ originate in the client SDK.
| Prop | Type | Default | Description |
|---|---|---|---|
ARLOPASS_SDK_INVALID_STATE_TRANSITION | SDK | — | Attempted an illegal state transition (e.g. connect while already connected). |
ARLOPASS_SDK_INVALID_STATE_OPERATION | SDK | — | Operation not valid in the current state (e.g. chat.send while disconnected). |
ARLOPASS_SDK_MISSING_PROVIDER_SELECTION | SDK | — | Chat operation attempted without selecting a provider first. |
ARLOPASS_SDK_PROTOCOL_VIOLATION | SDK | — | Response envelope failed validation. |
ARLOPASS_SDK_TRANSPORT_ERROR | SDK | — | Transport-level failure (network, serialization, etc.). |
Protocol machine codes
Codes prefixed with ARLOPASS_ or ARLOPASS_PROTOCOL_ originate in the protocol layer or extension.
| Prop | Type | Default | Description |
|---|---|---|---|
ARLOPASS_AUTH_FAILED | Protocol | — | Authentication failure (invalid credentials). |
ARLOPASS_PERMISSION_DENIED | Protocol | — | Caller lacks permission for the requested operation. |
ARLOPASS_TIMEOUT | Protocol | — | Request timed out. |
ARLOPASS_PROVIDER_UNAVAILABLE | Protocol | — | Selected provider is offline or unreachable. |
ARLOPASS_TRANSIENT_NETWORK | Protocol | — | Transient network error. |
ARLOPASS_POLICY_VIOLATION | Protocol | — | Request blocked by a policy rule. |
ARLOPASS_PROTOCOL_INVALID_ENVELOPE | Protocol | — | Envelope structure is invalid. |
ARLOPASS_PROTOCOL_MISSING_REQUIRED_FIELD | Protocol | — | A required field is missing from the envelope. |
ARLOPASS_PROTOCOL_ENVELOPE_EXPIRED | Protocol | — | Envelope TTL has expired. |
ARLOPASS_PROTOCOL_REPLAY_PRONE_METADATA | Protocol | — | Envelope metadata suggests a replay attack. |
ARLOPASS_PROTOCOL_UNSUPPORTED_VERSION | Protocol | — | Protocol version not supported. |
ARLOPASS_PROTOCOL_UNSUPPORTED_CAPABILITY | Protocol | — | Requested capability not supported. |
Reason codes
Normalized reason codes provide a human-readable classification. The SDK normalizes aliases (e.g. "timeout" → "transport.timeout").
| Prop | Type | Default | Description |
|---|---|---|---|
allow | Success | — | Operation succeeded. |
auth.invalid | Auth | — | Invalid credentials. |
auth.expired | Auth | — | Credentials have expired. |
permission.denied | Auth | — | Insufficient permissions. |
policy.denied | Policy | — | Blocked by policy. |
provider.unavailable | Provider | — | Provider is offline or unreachable. |
request.invalid | Request | — | Malformed request. |
request.replay_prone | Request | — | Request metadata suggests a replay. |
request.expired | Request | — | Request envelope has expired. |
protocol.unsupported_version | Protocol | — | Protocol version mismatch. |
protocol.unsupported_capability | Protocol | — | Capability not recognized. |
protocol.invalid_envelope | Protocol | — | Envelope validation failed. |
transport.timeout | Transport | — | Operation timed out. |
transport.cancelled | Transport | — | Operation was cancelled (e.g. AbortSignal). |
transport.transient_failure | Transport | — | Temporary network or transport issue. |
Retryable vs non-retryable
Every error has a retryable boolean. Use it to decide whether to surface a retry button or fail permanently.
| Prop | Type | Default | Description |
|---|---|---|---|
ArlopassTransportError | retryable: true | — | Transport failures are retryable by default. |
ArlopassTimeoutError | retryable: true | — | Timeouts are retryable by default. |
ArlopassStateError | retryable: false | — | State errors indicate logic bugs — not retryable. |
ArlopassInvalidStateTransitionError | retryable: false | — | Invalid transitions are logic bugs — not retryable. |
ArlopassProtocolBoundaryError | retryable: false | — | Protocol violations typically require a code fix. |
if (error instanceof ArlopassSDKError && error.retryable) {
await retry();
}