The Trustware SDK surfaces errors through a typedDocumentation Index
Fetch the complete documentation index at: https://docs.trustware.io/llms.txt
Use this file to discover all available pages before exploring further.
TrustwareError class, so you always know what went wrong and why. You can handle errors reactively via the onError callback, or imperatively by catching thrown errors in the headless core.
The TrustwareError class
TrustwareError extends the native Error class with three additional fields:
| Field | Type | Description |
|---|---|---|
code | TrustwareErrorCode | Machine-readable error code — use this for branching logic |
message | string | Technical description of the error |
userMessage | string | undefined | Optional human-readable message suitable for display |
cause | unknown | undefined | The original error that triggered this one, if any |
Error codes
TheTrustwareErrorCode enum covers all error conditions the SDK can produce.
| Code | Typical cause |
|---|---|
INVALID_CONFIG | The configuration object is missing required fields or has an invalid value |
INVALID_API_KEY | The API key was rejected — thrown during Trustware.init() |
WALLET_NOT_CONNECTED | A wallet operation was attempted before a wallet was connected |
BRIDGE_FAILED | The cross-chain bridge transaction could not be completed |
NETWORK_ERROR | A network request failed (timeout, DNS failure, or server error) |
INPUT_ERROR | The input to a core method (amount, address, etc.) is invalid |
UNKNOWN_ERROR | An unexpected error with no more specific classification |
Handling errors via onError
Pass an onError callback in your TrustwareConfigOptions to receive all errors emitted by the widget and provider. This is the simplest approach for most integrations.
error.userMessage when it is defined:
Handling errors with try/catch
When using the headless core API, errors are thrown as exceptions. Wrap core calls in atry/catch block.
The RateLimitError class
When your integration hits the API rate limit, the SDK throws a RateLimitError. It extends the native Error class directly (not TrustwareError), so a single instanceof TrustwareError check will not match it — handle it as a separate case.
rateLimitInfo property has the following shape:
| Field | Type | Description |
|---|---|---|
limit | number | Maximum requests allowed in the current window |
remaining | number | Requests remaining in the current window |
reset | number | Unix timestamp when the rate limit window resets |
retryAfter | number | undefined | Seconds until the limit resets (only present on 429 responses) |
By default, the SDK automatically retries rate-limited requests with exponential backoff up to 3 times.
RateLimitError is only thrown when all retries are exhausted. You can configure this behavior via the retry option in TrustwareConfigOptions.