Exception: OpenAI::Errors::OAuthError

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

Instance Attribute Summary collapse

Attributes inherited from APIStatusError

#code, #param, #type

Attributes inherited from APIError

#body, #code, #headers, #param, #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.



556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
# File 'lib/openai/errors.rb', line 556

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

  message = if (error_description = OpenAI::Internal::Util.dig(body, :error_description))
    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:



554
555
556
# File 'lib/openai/errors.rb', line 554

def error_code
  @error_code
end

Instance Method Details

#statusInteger

Returns:



148
# File 'sig/openai/errors.rbs', line 148

def status: -> Integer

#status=Integer

Parameters:

Returns:



150
# File 'sig/openai/errors.rbs', line 150

def status=: (Integer) -> Integer