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.



538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
# File 'lib/openai/errors.rb', line 538

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)


536
537
538
# File 'lib/openai/errors.rb', line 536

def error_code
  @error_code
end