Error Handling

Handle errors gracefully when using the DotPassport SDK.

DotPassportError

All API errors throw a DotPassportError instance with detailed information.

Import

import { DotPassportError } from '@dotpassport/sdk';

Properties

Property
Type
Description

message

string

Human-readable error message

statusCode

number

HTTP status code

response

any

Full error response from API

Example

try {
  const scores = await client.getScores(address);
} catch (error) {
  if (error instanceof DotPassportError) {
    console.log('Status:', error.statusCode);    // 404
    console.log('Message:', error.message);       // "User not found"
    console.log('Response:', error.response);     // Full error details
  }
}

Error Codes Reference

Status
Error
Description
Solution

400

Bad Request

Invalid parameters

Check request format

401

Unauthorized

Invalid/missing API key

Verify API key

403

Forbidden

Insufficient permissions

Check key permissions

404

Not Found

Resource doesn't exist

Verify address/key

429

Too Many Requests

Rate limit exceeded

Implement backoff

500

Internal Server Error

Server error

Retry with backoff

503

Service Unavailable

API is down

Retry later


Basic Error Handling


Specific Error Handling

Handle different error types with specific responses:


Retry Logic

Implement automatic retries for transient failures:


Error Recovery Patterns

Fallback Values

Graceful Degradation


React Error Boundary


Logging Errors


Last updated