Exception: OpenAI::Errors::OAuthError

Inherits:
APIStatusError show all
Defined in:
lib/openai/errors.rb

Instance Attribute Summary collapse

Attributes inherited from APIStatusError

#code, #param, #status, #type

Attributes inherited from APIError

#body, #code, #headers, #param, #status, #type, #url

Instance Method Summary collapse

Methods inherited from APIStatusError

for

Constructor Details

#initialize(status:, body:, headers:) ⇒ OAuthError

Returns a new instance of OAuthError.



271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
# File 'lib/openai/errors.rb', line 271

def initialize(status:, body:, headers:)
  @error_code = OpenAI::Internal::Type::Converter.coerce(OpenAI::Models::OAuthErrorCode, body&.dig(:error))

  message =
    if body&.dig(:error_description)
      body[:error_description]
    elsif @error_code
      @error_code
    else
      "OAuth2 authentication error"
    end

  super(
    url: URI("https://auth.openai.com/oauth/token"),
    status: status,
    headers: headers,
    body: body,
    request: nil,
    response: nil,
    message: message
  )
end

Instance Attribute Details

#error_codeOpenAI::Models::OAuthErrorCode::Variants? (readonly)

Returns:

  • (OpenAI::Models::OAuthErrorCode::Variants, nil)


269
270
271
# File 'lib/openai/errors.rb', line 269

def error_code
  @error_code
end