Handling ILLA SDK errors
When using theIllaSDK class, errors are returned as structured results.
sendMessage Error Handling
sendToolResult Error Handling
getMessages Error Handling
Advanced: Lower-Level Component Errors
Thrown errors (public)
PromptConfigurationConflict: CreatingPromptwith both or neithertext/toolResultCoreApiAuthenticationMissing: ConstructingCoreApiProviderwithoutx-api-keyCoreApiMethodNotImplemented: Server returned HTTP 501 to a provider call
Structured results
chat.sendMessage(prompt)returns an object withstatusand eitherresponseorerrorAsyncToolChecker.check(...)returns a discriminated union{ isError: boolean, response?: ..., error?: ... }
Long-running actions
Chat.awaitAction(...)throwsChatAsyncToolCheckerUnavailableif noAsyncToolCheckeris configured (note: this error class is not exported)AsyncToolChecker.subscribe(...)delivers issues viaonErrorcallback (e.g., timeouts, max retries) rather than throwing
Error Handling Best Practices
- Wrap SDK calls in try/catch when constructing objects or when a method documents it may throw
- Prefer discriminated unions and status codes for flow control over exceptions from network errors
- Log unexpected error shapes for observability