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

Attributes inherited from Error

#cause

Instance Method Summary collapse

Methods inherited from APIStatusError

for

Methods inherited from APIError

#request_id

Constructor Details

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

Returns a new instance of OAuthError.



278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
# File 'lib/openai/errors.rb', line 278

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)


276
277
278
# File 'lib/openai/errors.rb', line 276

def error_code
  @error_code
end