Error Types
The SDK provides specialized error classes for different error scenarios. All errors extend from SDKError.
SDKError (Base Class)
Base error class that all SDK errors extend from.
Properties:
message: string- Human-readable error messagecode: string- Error code for programmatic handlingdetails?: any- Additional error context
AuthenticationError
Thrown when authentication fails.
Common Causes:
Invalid credentials
Expired tokens
Malformed JWT tokens
Invalid signature
Example:
import { AuthenticationError } from "yieldfi-sdk";
try {
await sdk.auth.login(credentials);
} catch (error) {
if (error instanceof AuthenticationError) {
console.error("Auth failed:", error.message);
console.error("Code:", error.code);
console.error("Details:", error.details);
}
}NetworkError
Thrown for network-related errors.
Properties:
statusCode?: number- HTTP status coderesponse?: any- Response data (if available)
Common Causes:
Network connectivity issues
Request timeouts
HTTP errors (4xx, 5xx)
Server unavailable
Example:
ValidationError
Thrown when input validation fails.
Common Causes:
Missing required parameters
Invalid parameter types
Out-of-range values
Invalid format
Example:
ConfigurationError
Thrown when SDK configuration is invalid.
Common Causes:
Missing required configuration
Invalid configuration values
Invalid gateway URL format
Example:
Complete Error Handling Example
Error Codes
Common error codes you may encounter:
AUTH_FAILED- Authentication failedTOKEN_EXPIRED- Token expiredINVALID_TOKEN- Invalid token formatNETWORK_ERROR- Network request failedTIMEOUT- Request timeoutVALIDATION_ERROR- Input validation failedNOT_FOUND- Resource not foundFORBIDDEN- Access forbiddenSERVER_ERROR- Server error
Last updated