Skip to main content

Overview

The ZKScore SDK provides detailed error information to help you build robust applications. This guide covers error types, handling strategies, and best practices.

Error Structure

All SDK errors follow a consistent structure:

Common Error Codes

Authentication Errors

Code: INVALID_API_KEY
Status: 401
The provided API key is invalid or has been revoked.
Code: API_KEY_EXPIRED
Status: 401
The API key has expired and needs to be renewed.
Code: UNAUTHORIZED
Status: 403
The API key doesn’t have permission for this operation.

Resource Errors

Code: IDENTITY_NOT_FOUND
Status: 404
The address doesn’t have a ZKScore identity.
Code: USERNAME_TAKEN
Status: 409
The requested username is already in use.
Code: ACHIEVEMENT_NOT_FOUND
Status: 404
The specified achievement doesn’t exist.
Code: ATTESTATION_NOT_FOUND
Status: 404
The attestation ID doesn’t exist or has been revoked.

Rate Limiting

Code: RATE_LIMIT_EXCEEDED
Status: 429
Too many requests. Includes retry-after information.

Validation Errors

Code: INVALID_ADDRESS
Status: 400
The provided Ethereum address is invalid.
Code: INVALID_PARAMETERS
Status: 400
Request parameters are invalid or missing.
Code: INVALID_SCHEMA
Status: 400
Attestation schema is invalid or doesn’t exist.

Network Errors

Code: NETWORK_ERROR
Status: 500
Network connection failed.
Code: TIMEOUT
Status: 504
Request timed out.
Code: SERVICE_UNAVAILABLE
Status: 503
The service is temporarily unavailable.

Data Errors

Code: INSUFFICIENT_DATA
Status: 400
Not enough data to complete the operation.
Code: SCORE_NOT_READY
Status: 202
Score is still being calculated.

Error Handling Patterns

Basic Try-Catch

Specific Error Handling

Retry Logic

Rate Limit Handler

Circuit Breaker

Error Logging

Graceful Degradation

Error Boundaries (React)

Validation Helper

TypeScript Error Types

Best Practices

Always Handle Errors

Wrap all SDK calls in try-catch blocks

Provide Feedback

Show user-friendly error messages

Log Errors

Track errors for debugging and monitoring

Implement Retries

Retry transient failures with backoff

Validate Input

Validate before making API calls

Graceful Degradation

Provide fallbacks when possible

Next Steps

Rate Limiting Guide

Learn about rate limits

Best Practices

SDK best practices

API Reference

Complete API documentation

Error Codes Reference

All error codes