Overview
The RunAnywhere SDK provides structured error handling throughSDKError with specific error codes and categories. This guide covers error types, handling patterns, and recovery strategies.
SDKError Structure
Checking for SDK Errors
Error Codes
General Errors
| Code | Description | Recovery |
|---|---|---|
notInitialized | SDK not initialized | Call RunAnywhere.initialize() |
alreadyInitialized | SDK already initialized | Use existing instance or call reset() |
invalidInput | Invalid input parameters | Check input values |
nativeModuleNotAvailable | Native module not linked | Rebuild app, check pod install |
Model Errors
| Code | Description | Recovery |
|---|---|---|
modelNotFound | Model not in registry | Add model with LlamaCPP.addModel() |
modelLoadFailed | Failed to load model | Check model path, format, memory |
modelNotLoaded | No model loaded | Call loadModel() first |
modelDownloadFailed | Download failed | Check network, retry |
Generation Errors
| Code | Description | Recovery |
|---|---|---|
generationFailed | Text generation failed | Check model, reduce tokens |
generationCancelled | Generation was cancelled | Expected if cancelGeneration() called |
Voice Errors
| Code | Description | Recovery |
|---|---|---|
sttFailed | Transcription failed | Check audio format, model |
ttsFailed | Synthesis failed | Check TTS model, text |
vadFailed | VAD failed | Check VAD configuration |
voiceAgentFailed | Voice pipeline failed | Check all models loaded |
Resource Errors
| Code | Description | Recovery |
|---|---|---|
insufficientStorage | Not enough disk space | Free storage, delete models |
insufficientMemory | Not enough RAM | Unload models, use smaller model |
downloadFailed | Download failed | Check network, storage |
downloadCancelled | Download cancelled | Expected if cancelled by user |
Network/Auth Errors
| Code | Description | Recovery |
|---|---|---|
networkUnavailable | No network connection | Check connectivity |
authenticationFailed | Invalid API key | Check API key |
permissionDenied | Missing permission | Request permission |
Error Categories
Handling Patterns
Comprehensive Error Handler
Category-Based Handling
React Hook for Error Handling
useSDKError.ts
Error Display Component
ErrorDisplay.tsx