lib/ruby_conversations/errors.rb



# frozen_string_literal: true

module RubyConversations
  # Base error class for the gem
  class Error < StandardError; end

  # Error raised when there is a configuration issue
  class ConfigurationError < Error; end

  # Error raised when there is an error with the client
  class ClientError < StandardError
    attr_reader :status_code

    def initialize(message, status_code: nil)
      super(message)
      @status_code = status_code
    end
  end

  # Error raised when a template is not found
  class TemplateNotFoundError < Error; end

  # Error raised when tool calls are expected but not found in LLM response
  class ToolCallValidationError < Error
    attr_reader :last_message, :tool_names

    def initialize(message, last_message: nil, tool_names: nil)
      super(message)
      @last_message = last_message
      @tool_names = tool_names
    end
  end
end