Comprehensive error handling for LiteLLM-clj
This namespace provides:
Comprehensive error handling for LiteLLM-clj This namespace provides: - Namespaced error types for clear categorization - Rich error data structures with context - Error predicates for pattern matching - Retry and recoverability analysis
(authentication-error provider
                      message
                      &
                      {:keys [http-status provider-code] :as opts})API key invalid or missing
API key invalid or missing
(authorization-error provider
                     message
                     &
                     {:keys [http-status provider-code resource] :as opts})API key valid but lacks permissions
API key valid but lacks permissions
(chunk->exception chunk)Convert an error chunk to an exception
Convert an error chunk to an exception
(client-error? ex)Check if error is a client/configuration error
Check if error is a client/configuration error
(connection-error provider message & {:keys [cause request-id] :as opts})Network connectivity issues
Network connectivity issues
(content-filter provider message & {:keys [provider-code filter-type] :as opts})Content filtered by provider safety systems
Content filtered by provider safety systems
(error-chunk? chunk)Check if a streaming chunk is an error chunk
Check if a streaming chunk is an error chunk
(error-details ex)Get detailed error information as a map
Get detailed error information as a map
(error-summary ex)Create a human-readable error summary
Create a human-readable error summary
(error-type? ex error-type)Check if exception matches a specific error type
Check if exception matches a specific error type
(get-error-category ex)Get human-readable error category
Get human-readable error category
(http-status->error status
                    provider
                    message
                    &
                    {:keys [provider-code retry-after request-id body]
                     :as opts})Map HTTP status code to appropriate error constructor
Map HTTP status code to appropriate error constructor
(internal-error message & {:keys [cause stack-trace] :as opts})Unexpected litellm bug
Unexpected litellm bug
(invalid-config message & {:keys [config errors] :as opts})Configuration validation failed
Configuration validation failed
(invalid-request message & {:keys [request errors] :as opts})Request validation failed - missing required fields or invalid types
Request validation failed - missing required fields or invalid types
(invalid-response provider
                  message
                  &
                  {:keys [response validation-errors] :as opts})Response doesn't match expected schema
Response doesn't match expected schema
(litellm-error? ex)Check if exception is a litellm error
Check if exception is a litellm error
(model-not-found provider
                 model
                 &
                 {:keys [http-status provider-code available-models] :as opts})Model doesn't exist for provider
Model doesn't exist for provider
(provider-error provider
                message
                &
                {:keys [http-status provider-code request-id recoverable?]
                 :as opts})Generic provider-side error
Generic provider-side error
(provider-error? ex)Check if error is a provider/network error
Check if error is a provider/network error
(provider-not-found provider & {:keys [available-providers] :as opts})Requested provider doesn't exist
Requested provider doesn't exist
(quota-exceeded provider
                message
                &
                {:keys [http-status provider-code quota-type reset-at]
                 :as opts})Account quota exhausted
Account quota exhausted
(rate-limit provider
            message
            &
            {:keys [http-status provider-code retry-after request-id] :as opts})Rate limit hit - usually recoverable with backoff
Rate limit hit - usually recoverable with backoff
(recoverable? ex)Check if error is recoverable (retry might succeed)
Check if error is recoverable (retry might succeed)
(resource-exhausted message
                    &
                    {:keys [resource-type current-usage limit] :as opts})Thread pool or channel buffer full
Thread pool or channel buffer full
(response-error? ex)Check if error is a response error
Check if error is a response error
(retry-delay ex retry-count)Calculate retry delay in milliseconds based on error type and retry count
Calculate retry delay in milliseconds based on error type and retry count
(server-error provider
              message
              &
              {:keys [http-status provider-code request-id] :as opts})Provider's server error (500, 502, 503)
Provider's server error (500, 502, 503)
(should-retry? ex
               &
               {:keys [max-retries current-retry]
                :or {max-retries 3 current-retry 0}})Determine if error should be retried based on type and recoverability
Determine if error should be retried based on type and recoverability
(streaming-error provider
                 message
                 &
                 {:keys [recoverable? chunk-number cause] :as opts})Error during streaming operation
Error during streaming operation
(streaming-error-chunk
  provider
  message
  &
  {:keys [error-type http-status provider-code recoverable? chunk-number cause]
   :or {error-type :litellm/streaming-error recoverable? false}})Create an error chunk for placing on streaming channels
Create an error chunk for placing on streaming channels
(system-error? ex)Check if error is a system error
Check if error is a system error
(timeout-error provider message & {:keys [timeout-ms request-id] :as opts})Request timeout
Request timeout
(unsupported-feature provider feature & {:keys [message] :as opts})Feature not supported by provider
Feature not supported by provider
(wrap-http-errors provider-name f)Wrap HTTP calls to convert hato exceptions to litellm errors. Preserves HTTP response details when available.
Wrap HTTP calls to convert hato exceptions to litellm errors. Preserves HTTP response details when available.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs | 
| ← | Move to previous article | 
| → | Move to next article | 
| Ctrl+/ | Jump to the search field |