Exception: Basecamp::Oauth::OauthError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/basecamp/oauth/oauth_error.rb

Overview

OAuth-specific error class.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, message, http_status: nil, hint: nil, retryable: false) ⇒ OauthError

Returns a new instance of OauthError.

Parameters:

  • type (String)

    Error type

  • message (String)

    Error message

  • http_status (Integer, nil) (defaults to: nil)

    HTTP status code

  • hint (String, nil) (defaults to: nil)

    Helpful hint

  • retryable (Boolean) (defaults to: false)

    Whether retryable



21
22
23
24
25
26
27
# File 'lib/basecamp/oauth/oauth_error.rb', line 21

def initialize(type, message, http_status: nil, hint: nil, retryable: false)
  super(message)
  @type = type
  @http_status = http_status
  @hint = hint
  @retryable = retryable
end

Instance Attribute Details

#hintString?

Helpful hint for resolving the error

Returns:

  • (String, nil)

    the current value of hint



13
14
15
# File 'lib/basecamp/oauth/oauth_error.rb', line 13

def hint
  @hint
end

#http_statusInteger?

HTTP status code if applicable

Returns:

  • (Integer, nil)

    the current value of http_status



13
14
15
# File 'lib/basecamp/oauth/oauth_error.rb', line 13

def http_status
  @http_status
end

#retryableBoolean

Whether the request can be retried

Returns:

  • (Boolean)

    the current value of retryable



13
14
15
# File 'lib/basecamp/oauth/oauth_error.rb', line 13

def retryable
  @retryable
end

#typeString

Error type ("validation", "auth", "network", "api_error", or "usage" — the parent type DeviceFlowError derives for a cancelled device flow)

Returns:

  • (String)

    the current value of type



13
14
15
# File 'lib/basecamp/oauth/oauth_error.rb', line 13

def type
  @type
end

Instance Method Details

#to_sObject



29
30
31
32
33
34
# File 'lib/basecamp/oauth/oauth_error.rb', line 29

def to_s
  parts = [ "[#{type}] #{super}" ]
  parts << "(HTTP #{http_status})" if http_status
  parts << "Hint: #{hint}" if hint
  parts.join(" ")
end