Errors
The SDK provides typed error classes for precise error handling.Error Hierarchy
BorrowSDKError
Base error class for all SDK errors.Properties
| Property | Type | Description |
|---|---|---|
code | ErrorCode | Error classification |
context | object | Additional error context |
message | string | Error message |
Example
WalletNotConnectedError
Thrown when a wallet operation is attempted without a connected wallet.Default Code
ErrorCode.WALLET_NOT_CONNECTED
Common Causes
- Calling methods before wallet is connected
- Wallet disconnected during operation
- Missing wallet provider in config
Example
SmartAccountError
Thrown when smart account operations fail.Default Code
ErrorCode.SMART_ACCOUNT_ERROR
Common Causes
- Signature verification failed
- Smart account derivation failed
- Session authorization failed
- Account not initialized
Example
ApiError
Thrown when API requests fail.Default Code
ErrorCode.API_ERROR
Properties
| Property | Type | Description |
|---|---|---|
statusCode | number | HTTP status code |
Common Status Codes
| Code | Meaning |
|---|---|
| 400 | Bad request / validation error |
| 401 | Unauthorized / invalid API key |
| 403 | Forbidden |
| 404 | Resource not found |
| 429 | Rate limited |
| 500 | Server error |
Example
ConfigValidationError
Thrown when SDK configuration is invalid.Default Code
ErrorCode.CONFIG_ERROR
Common Causes
- Missing required config options
- Invalid config values
- Invalid URL format
- Invalid chain type
Example
Validation Rules
| Option | Validation |
|---|---|
apiKey | Non-empty string |
baseUrl | Valid URL |
chain | Valid ChainType |
wallet.address | Non-empty string |
wallet.signMessage | Function |
workflowPollInterval | >= 100 |
sessionValiditySeconds | >= 60 |
QuoteError
Thrown when quote operations fail.Default Code
ErrorCode.QUOTE_ERROR
Common Causes
- No quotes available for parameters
- Invalid quote parameters
- Quote expired
Example
WorkflowError
Thrown when workflow operations fail.Default Code
ErrorCode.WORKFLOW_ERROR
Properties
| Property | Type | Description |
|---|---|---|
workflowId | string | Failed workflow ID |
Common Causes
- Workflow timeout
- Deposit not received
- Bridge failure
- Execution failure