Class: LLM::Bedrock::ErrorHandler Private

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

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Handles Bedrock API error responses.

Bedrock errors come as JSON with:

{ "message" => "...", "__type" => "..." }

or as standard HTTP status codes.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:



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

def initialize(tracer, span, res)
  @tracer = tracer
  @span = span
  @res = res
end

Instance Attribute Details

#resNet::HTTPResponse (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Net::HTTPResponse)


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

def res
  @res
end

#spanObject? (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:



19
20
21
# File 'lib/llm/providers/bedrock/error_handler.rb', line 19

def span
  @span
end

Instance Method Details

#raise_error!Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Raises:



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

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