Exception: RubyLLM::ToolCallParseError

Inherits:
Error
  • Object
show all
Defined in:
lib/ruby_llm/error.rb

Overview

Raised when a provider returns tool-call arguments that are not valid JSON, often because the response was truncated mid-tool-call.

Instance Attribute Summary collapse

Attributes inherited from Error

#response

Instance Method Summary collapse

Methods inherited from Error

default_message

Constructor Details

#initialize(message = nil, response: nil, finish_reason: nil) ⇒ ToolCallParseError

:nodoc:



132
133
134
135
136
137
# File 'lib/ruby_llm/error.rb', line 132

def initialize(message = nil, response: nil, finish_reason: nil) # :nodoc:
  @finish_reason = finish_reason
  message ||= 'Provider returned malformed tool call arguments'
  message = "#{message} (finish_reason: #{finish_reason})" if finish_reason
  super(message, response: response)
end

Instance Attribute Details

#finish_reasonObject (readonly)

Returns the normalized reason generation stopped, or nil.



130
131
132
# File 'lib/ruby_llm/error.rb', line 130

def finish_reason
  @finish_reason
end