Error Handling
Overview
The YieldFi SDK provides specialized error classes for different error scenarios. All errors extend from SDKError and include detailed information.
Error Types
SDKError- Base error classAuthenticationError- Authentication failuresNetworkError- Network and HTTP errorsValidationError- Input validation errorsConfigurationError- SDK configuration errors
Quick Example
import {
AuthenticationError,
NetworkError,
ValidationError,
} from "yieldfi-sdk";
try {
const vault = await sdk.vault.getVaultByKey("yusd", 1);
} catch (error) {
if (error instanceof AuthenticationError) {
console.error("Auth failed:", error.message);
} else if (error instanceof NetworkError) {
console.error("Network error:", error.statusCode);
} else if (error instanceof ValidationError) {
console.error("Validation error:", error.message);
}
}Next Steps
Error Types - Detailed error type reference
Best Practices - Error handling best practices
Last updated