Skip to Content

Error Handling

The SDK implements comprehensive error handling through the LombardError class. All errors can be identified using the isLombardError() utility function.


Error Structure

Each error contains:

PropertyTypeDescription
codeAnyErrorCodeMachine-readable error code
messagestringHuman-readable description
metadataRecord<string, unknown>Additional context

Error Categories

General Errors

CodeDescription
unknown-errorAn unexpected error occurred
invalid-configurationSDK configuration is invalid
operation-timeoutOperation timed out
operation-cancelledUser cancelled the operation

Provider Errors

CodeDescription
provider-missingRequired wallet provider not configured
provider-initialization-failedFailed to initialize wallet provider
provider-call-failedWallet provider method call failed
signer-missingTransaction signer not available
user-rejectedUser rejected the transaction or signature
network-mismatchWallet is connected to wrong network

Validation Errors

CodeDescription
invalid-addressAddress format is invalid
invalid-amountAmount format is invalid
amount-too-smallAmount is below minimum
amount-too-largeAmount is above maximum
insufficient-balanceNot enough balance for operation
invalid-parameterParameter value is invalid
missing-required-parameterRequired parameter was not provided
invalid-chainChain is not supported
invalid-stateAction is in invalid state for operation
invalid-assetAsset is not supported

Contract Errors

CodeDescription
contract-call-failedSmart contract call failed
transaction-failedTransaction execution failed
transaction-revertedTransaction was reverted
approval-failedToken approval failed
insufficient-allowanceToken allowance is too low
gas-estimation-failedCould not estimate gas

Registry Errors

CodeDescription
route-not-foundNo matching route found
invalid-route-definitionRoute definition is invalid
unsupported-chainChain is not supported in environment
unsupported-assetAsset is not supported
incompatible-routeRoute is incompatible with parameters
environment-mismatchEnvironment mismatch

Implementation Pattern

import { isLombardError } from '@lombard.finance/sdk'; try { await stake.authorize(); } catch (error) { if (isLombardError(error)) { switch (error.code) { case 'user-rejected': // User cancelled - show retry option break; case 'network-mismatch': // Prompt user to switch networks break; case 'amount-too-small': // Show minimum amount from error.metadata break; default: console.error(error.code, error.message); } } }

The framework preserves action state across errors, allowing direct retry of failed operations without resetting the workflow.

Last updated on