Class: OpenaiAssistant::ErrorResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/openai_assistant/error_response.rb

Overview

A error response of openai

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ ErrorResponse

Returns a new instance of ErrorResponse.



15
16
17
18
19
# File 'lib/openai_assistant/error_response.rb', line 15

def initialize(**args)
  args.each do |k, v|
    instance_variable_set("@#{k}", v) unless v.nil?
  end
end

Instance Attribute Details

#codeString

Returns error code of openai.

Returns:

  • (String)

    error code of openai



13
14
15
# File 'lib/openai_assistant/error_response.rb', line 13

def code
  @code
end

#messageString

Returns error message.

Returns:

  • (String)

    error message



7
8
9
# File 'lib/openai_assistant/error_response.rb', line 7

def message
  @message
end

#paramString

Returns parameter that caused the error.

Returns:

  • (String)

    parameter that caused the error



11
12
13
# File 'lib/openai_assistant/error_response.rb', line 11

def param
  @param
end

#typeString

Returns type of error.

Returns:

  • (String)

    type of error



9
10
11
# File 'lib/openai_assistant/error_response.rb', line 9

def type
  @type
end

Class Method Details

.from_json(response_body) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/openai_assistant/error_response.rb', line 21

def self.from_json(response_body)
  data = JSON.parse(response_body)["error"]
  OpenaiAssistant::ErrorResponse.new(
    message: data["message"],
    type: data["type"],
    param: data["param"],
    code: data["code"]
  )
end