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



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

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



11
12
13
# File 'lib/basecamp/oauth/oauth_error.rb', line 11

def hint
  @hint
end

#http_statusInteger?

HTTP status code if applicable

Returns:

  • (Integer, nil)

    the current value of http_status



11
12
13
# File 'lib/basecamp/oauth/oauth_error.rb', line 11

def http_status
  @http_status
end

#retryableBoolean

Whether the request can be retried

Returns:

  • (Boolean)

    the current value of retryable



11
12
13
# File 'lib/basecamp/oauth/oauth_error.rb', line 11

def retryable
  @retryable
end

#typeString

Error type ("validation", "auth", "network", "api_error")

Returns:

  • (String)

    the current value of type



11
12
13
# File 'lib/basecamp/oauth/oauth_error.rb', line 11

def type
  @type
end

Instance Method Details

#to_sObject



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

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