Exception: GroqRuby::APIStatusError

Inherits:
APIError show all
Defined in:
lib/groq_ruby/errors/api_status_error.rb

Overview

4xx/5xx response. Carries status, headers, and the parsed body.

Instance Attribute Summary collapse

Attributes inherited from APIError

#request

Instance Method Summary collapse

Constructor Details

#initialize(message, status:, headers: {}, body: nil, request: nil) ⇒ APIStatusError

Returns a new instance of APIStatusError.

Parameters:

  • message (String)
  • status (Integer)
  • headers (Hash{String => String}) (defaults to: {})
  • body (Hash, String, nil) (defaults to: nil)
  • request (Object, nil) (defaults to: nil)


16
17
18
19
20
21
# File 'lib/groq_ruby/errors/api_status_error.rb', line 16

def initialize(message, status:, headers: {}, body: nil, request: nil)
  @status = status
  @headers = headers
  @body = body
  super(message, request: request)
end

Instance Attribute Details

#bodyHash, ... (readonly)

Returns decoded JSON body or raw String.

Returns:

  • (Hash, String, nil)

    decoded JSON body or raw String



9
10
11
# File 'lib/groq_ruby/errors/api_status_error.rb', line 9

def body
  @body
end

#headersHash{String => String} (readonly)

Returns response headers.

Returns:

  • (Hash{String => String})

    response headers



7
8
9
# File 'lib/groq_ruby/errors/api_status_error.rb', line 7

def headers
  @headers
end

#statusInteger (readonly)

Returns HTTP status code.

Returns:

  • (Integer)

    HTTP status code



5
6
7
# File 'lib/groq_ruby/errors/api_status_error.rb', line 5

def status
  @status
end