Exception: Google::Genai::APIError

Inherits:
Error
  • Object
show all
Defined in:
lib/google/genai/errors.rb

Direct Known Subclasses

ClientError, ServerError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, response_json, response) ⇒ APIError

Returns a new instance of APIError.



11
12
13
14
15
16
17
18
19
# File 'lib/google/genai/errors.rb', line 11

def initialize(code, response_json, response)
  @response = response
  @details = response_json.is_a?(Array) && response_json.length == 1 ? response_json[0] : response_json
  @message = get_message(@details)
  @status = get_status(@details)
  @code = code || get_code(@details)

  super("#{@code} #{@status}. #{@details}")
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



9
10
11
# File 'lib/google/genai/errors.rb', line 9

def code
  @code
end

#detailsObject (readonly)

Returns the value of attribute details.



9
10
11
# File 'lib/google/genai/errors.rb', line 9

def details
  @details
end

#responseObject (readonly)

Returns the value of attribute response.



9
10
11
# File 'lib/google/genai/errors.rb', line 9

def response
  @response
end

#statusObject (readonly)

Returns the value of attribute status.



9
10
11
# File 'lib/google/genai/errors.rb', line 9

def status
  @status
end