org.llm4s.error

package org.llm4s.error

Members list

Type members

Classlikes

final case class APIError extends LLMError

API errors for external service calls

API errors for external service calls

Attributes

Companion
object
Supertypes
trait LLMError
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object APIError

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
APIError.type
sealed abstract class AssistantError extends Product, Serializable

Assistant-specific error types with rich context and formatting

Assistant-specific error types with rich context and formatting

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Known subtypes
class DisplayError
class EOFError
class FileError
class IOError
class SessionError
Show all

Attributes

Companion
class
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
final case class AuthenticationError extends LLMError

Authentication-related errors

Authentication-related errors

Attributes

Companion
object
Supertypes
trait LLMError
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
final case class ConfigurationError extends LLMError

Attributes

Companion
object
Supertypes
trait LLMError
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
final case class ContextError extends LLMError

Context management related errors for token windows and conversation handling

Context management related errors for token windows and conversation handling

Attributes

Companion
object
Supertypes
trait LLMError
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object ContextError

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
object ErrorRecovery

Advanced pattern matching for error recovery and intelligent retry logic.

Advanced pattern matching for error recovery and intelligent retry logic.

Uses Scala's powerful pattern matching to implement sophisticated error handling strategies with type-safe recovery patterns.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
final case class ExecutionError(message: String, operation: String, exitCode: Option[Int], cause: Option[Throwable], context: Map[String, String]) extends LLMError

Execution errors that might succeed on retry.

Execution errors that might succeed on retry.

Represents errors from command or process execution that may be transient, such as temporary resource unavailability or intermittent failures. As a RecoverableError, retry strategies can be applied.

Value parameters

cause

Optional underlying exception

context

Additional key-value context for debugging

exitCode

Optional process exit code if applicable

message

Human-readable error description

operation

The operation that failed (e.g., "bash-script", "api-call")

Attributes

Example
val error = ExecutionError("Command failed", "bash-script")
 .withExitCode(1)
 .withContext("command", "npm install")
Supertypes
trait LLMError
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class InvalidInputError extends LLMError

Error for invalid input values that fail validation.

Error for invalid input values that fail validation.

Provides detailed context about which field was invalid, what value was provided, and why it was rejected. As a NonRecoverableError, the input must be corrected before retrying.

Value parameters

field

The name of the field that has invalid input

message

Human-readable error description

reason

Explanation of why the value is invalid

value

The invalid value that was provided

Attributes

Example
val error = InvalidInputError("temperature", "2.5", "must be between 0 and 1")
error.context  // Map("field" -> "temperature", "value" -> "2.5", "reason" -> "...")
Companion
object
Supertypes
trait LLMError
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Factory methods for creating InvalidInputError instances.

Factory methods for creating InvalidInputError instances.

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
trait LLMError extends Product, Serializable

Enhanced comprehensive error hierarchy for LLM operations using ADTs.

Enhanced comprehensive error hierarchy for LLM operations using ADTs.

This replaces the simple org.llm4s.llmconnect.model.LLMError with a much more comprehensive error system.

Key improvements over legacy version:

  • Structured context information
  • Recovery guidance built-in - Trait-based recoverability
  • Provider-agnostic design
  • Rich error formatting
  • Type-safe error handling
  • Private case class constructors with smart constructors

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Known subtypes
object LLMError

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
LLMError.type
final case class NetworkError extends LLMError

Network-related errors

Network-related errors

Attributes

Companion
object
Supertypes
trait LLMError
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object NetworkError

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
final case class NotFoundError(message: String, key: String) extends LLMError

Error indicating a required configuration or environment value was not found.

Error indicating a required configuration or environment value was not found.

Use this error when a required configuration key, environment variable, or resource is missing. As a NonRecoverableError, the operation cannot proceed without providing the missing value.

Value parameters

key

The configuration key or identifier that was not found

message

Human-readable error description

Attributes

Example
val error = NotFoundError("API key not found", "OPENAI_API_KEY")
error.context  // Map("key" -> "OPENAI_API_KEY")
Supertypes
trait LLMError
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class ProcessingError extends LLMError

Processing errors for operations like image processing, audio processing, etc.

Processing errors for operations like image processing, audio processing, etc.

Attributes

Companion
object
Supertypes
trait LLMError
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
final case class RateLimitError extends LLMError

Rate limiting errors - typically recoverable with exponential backoff

Rate limiting errors - typically recoverable with exponential backoff

Attributes

Companion
object
Supertypes
trait LLMError
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
final case class ServiceError extends LLMError

Service-level errors from LLM providers

Service-level errors from LLM providers

Attributes

Companion
object
Supertypes
trait LLMError
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object ServiceError

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
final case class SimpleError extends LLMError

A simple error with just a message and no additional context.

A simple error with just a message and no additional context.

Use this error type for basic error cases where no structured context is needed. For errors with more context, prefer specific error types like ValidationError or ConfigurationError.

Value parameters

message

Human-readable error description

Attributes

Example
val error = SimpleError("Something went wrong")
error.message  // "Something went wrong"
error.context  // Map.empty
Companion
object
Supertypes
trait LLMError
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object SimpleError

Factory methods for creating SimpleError instances.

Factory methods for creating SimpleError instances.

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
final case class SystemError extends LLMError

System-level errors for unexpected exceptions that may be transient.

System-level errors for unexpected exceptions that may be transient.

Represents unexpected system failures such as resource exhaustion, temporary unavailability, or other transient issues. As a RecoverableError, these can be retried with appropriate backoff strategies.

Value parameters

cause

Optional underlying exception

message

Human-readable error description

Attributes

Example
val error = SystemError("Unexpected memory allocation failure", Some(cause))
error.context  // Map("exceptionType" -> "OutOfMemoryError")
Companion
object
Supertypes
trait LLMError
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object SystemError

Factory methods for creating SystemError instances.

Factory methods for creating SystemError instances.

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
object ThrowableOps

Extension methods for converting Throwable to domain-specific LLMError types.

Extension methods for converting Throwable to domain-specific LLMError types.

Provides a uniform way to convert exceptions into the LLM4S error hierarchy, enabling consistent error handling across the codebase.

Attributes

Example
import org.llm4s.error.ThrowableOps._
val error = new java.net.SocketTimeoutException("timeout").toLLMError
// Returns NetworkError("Request timeout", ...)
// With custom mapper
implicit val mapper: ErrorMapper = customMapper
val customError = exception.toLLMError
Supertypes
class Object
trait Matchable
class Any
Self type
final case class TimeoutError(message: String, timeoutDuration: Duration, operation: String, cause: Option[Throwable], context: Map[String, String]) extends LLMError

Timeout errors that can potentially succeed with a different timeout or retry.

Timeout errors that can potentially succeed with a different timeout or retry.

Represents operations that exceeded their time limit. As a RecoverableError, these can be retried with longer timeouts or exponential backoff strategies.

Value parameters

cause

Optional underlying exception

context

Additional key-value context for debugging

message

Human-readable error description

operation

The operation that timed out (e.g., "api-call", "completion")

timeoutDuration

The timeout duration that was exceeded

Attributes

Example
import scala.concurrent.duration._
val error = TimeoutError("Request timed out", 30.seconds, "api-call")
 .withContext("endpoint", "https://api.openai.com")
Supertypes
trait LLMError
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class TokenizerError extends LLMError

Tokenizer-related errors for context management

Tokenizer-related errors for context management

Attributes

Companion
object
Supertypes
trait LLMError
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
final case class UnknownError extends LLMError

Unknown/unexpected errors with full exception context

Unknown/unexpected errors with full exception context

Attributes

Companion
object
Supertypes
trait LLMError
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object UnknownError

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
final case class ValidationError extends LLMError

Validation errors for malformed requests

Validation errors for malformed requests

Attributes

Companion
object
Supertypes
trait LLMError
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type