Class: BddOpenai::ErrorResponse
- Inherits:
-
Object
- Object
- BddOpenai::ErrorResponse
- Defined in:
- lib/bdd_openai/error_response.rb
Overview
A error response of openai
Instance Attribute Summary collapse
-
#code ⇒ String
Error code of openai.
-
#message ⇒ String
Error message.
-
#param ⇒ String
Parameter that caused the error.
-
#type ⇒ String
Type of error.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(**args) ⇒ ErrorResponse
constructor
A new instance of ErrorResponse.
Constructor Details
#initialize(**args) ⇒ ErrorResponse
Returns a new instance of ErrorResponse.
27 28 29 30 31 |
# File 'lib/bdd_openai/error_response.rb', line 27 def initialize(**args) args.each do |k, v| instance_variable_set("@#{k}", v) unless v.nil? end end |
Instance Attribute Details
#code ⇒ String
Returns error code of openai.
13 14 15 |
# File 'lib/bdd_openai/error_response.rb', line 13 def code @code end |
#message ⇒ String
Returns error message.
7 8 9 |
# File 'lib/bdd_openai/error_response.rb', line 7 def @message end |
#param ⇒ String
Returns parameter that caused the error.
11 12 13 |
# File 'lib/bdd_openai/error_response.rb', line 11 def param @param end |
#type ⇒ String
Returns type of error.
9 10 11 |
# File 'lib/bdd_openai/error_response.rb', line 9 def type @type end |
Class Method Details
.from_json(response_body) ⇒ BddOpenai::ErrorResponse
17 18 19 20 21 22 23 24 25 |
# File 'lib/bdd_openai/error_response.rb', line 17 def self.from_json(response_body) data = JSON.parse(response_body)['error'] BddOpenai::ErrorResponse.new( message: data['message'], type: data['type'], param: data['param'], code: data['code'] ) end |