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
INVALID_API_KEY
INVALID_API_KEY
Code:
Status: 401The provided API key is invalid or has been revoked.
INVALID_API_KEYStatus: 401The provided API key is invalid or has been revoked.
API_KEY_EXPIRED
API_KEY_EXPIRED
Code:
Status: 401The API key has expired and needs to be renewed.
API_KEY_EXPIREDStatus: 401The API key has expired and needs to be renewed.
UNAUTHORIZED
UNAUTHORIZED
Resource Errors
IDENTITY_NOT_FOUND
IDENTITY_NOT_FOUND
Code:
Status: 404The address doesn’t have a ZKScore identity.
IDENTITY_NOT_FOUNDStatus: 404The address doesn’t have a ZKScore identity.
USERNAME_TAKEN
USERNAME_TAKEN
Code:
Status: 409The requested username is already in use.
USERNAME_TAKENStatus: 409The requested username is already in use.
ACHIEVEMENT_NOT_FOUND
ACHIEVEMENT_NOT_FOUND
Code:
Status: 404The specified achievement doesn’t exist.
ACHIEVEMENT_NOT_FOUNDStatus: 404The specified achievement doesn’t exist.
ATTESTATION_NOT_FOUND
ATTESTATION_NOT_FOUND
Code:
Status: 404The attestation ID doesn’t exist or has been revoked.
ATTESTATION_NOT_FOUNDStatus: 404The attestation ID doesn’t exist or has been revoked.
Rate Limiting
RATE_LIMIT_EXCEEDED
RATE_LIMIT_EXCEEDED
Code:
Status: 429Too many requests. Includes retry-after information.
RATE_LIMIT_EXCEEDEDStatus: 429Too many requests. Includes retry-after information.
Validation Errors
INVALID_ADDRESS
INVALID_ADDRESS
Code:
Status: 400The provided Ethereum address is invalid.
INVALID_ADDRESSStatus: 400The provided Ethereum address is invalid.
INVALID_PARAMETERS
INVALID_PARAMETERS
Code:
Status: 400Request parameters are invalid or missing.
INVALID_PARAMETERSStatus: 400Request parameters are invalid or missing.
INVALID_SCHEMA
INVALID_SCHEMA
Code:
Status: 400Attestation schema is invalid or doesn’t exist.
INVALID_SCHEMAStatus: 400Attestation schema is invalid or doesn’t exist.
Network Errors
NETWORK_ERROR
NETWORK_ERROR
Code:
Status: 500Network connection failed.
NETWORK_ERRORStatus: 500Network connection failed.
TIMEOUT
TIMEOUT
Code:
Status: 504Request timed out.
TIMEOUTStatus: 504Request timed out.
SERVICE_UNAVAILABLE
SERVICE_UNAVAILABLE
Data Errors
INSUFFICIENT_DATA
INSUFFICIENT_DATA
Code:
Status: 400Not enough data to complete the operation.
INSUFFICIENT_DATAStatus: 400Not enough data to complete the operation.
SCORE_NOT_READY
SCORE_NOT_READY
Code:
Status: 202Score is still being calculated.
SCORE_NOT_READYStatus: 202Score 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