Class: LLM::Anthropic::ErrorHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/llm/providers/anthropic/error_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tracer, span, res) ⇒ LLM::Anthropic::ErrorHandler

Parameters:



25
26
27
28
29
# File 'lib/llm/providers/anthropic/error_handler.rb', line 25

def initialize(tracer, span, res)
  @tracer = tracer
  @span = span
  @res = LLM::Transport::Response.from(res)
end

Instance Attribute Details

#resLLM::Transport::Response (readonly)

Returns Non-2XX response from the server.

Returns:



10
11
12
# File 'lib/llm/providers/anthropic/error_handler.rb', line 10

def res
  @res
end

#spanObject? (readonly)

Returns The span.

Returns:



15
16
17
# File 'lib/llm/providers/anthropic/error_handler.rb', line 15

def span
  @span
end

Instance Method Details

#raise_error!Object

Raises:



34
35
36
37
38
39
# File 'lib/llm/providers/anthropic/error_handler.rb', line 34

def raise_error!
  ex = error
  @tracer.on_request_error(ex:, span:)
ensure
  raise(ex) if ex
end