Exception: Safire::Errors::AuthError

Inherits:
Error
  • Object
show all
Defined in:
lib/safire/errors.rb

Overview

Raised when an authorization request fails.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status: nil, error_code: nil, error_description: nil) ⇒ AuthError

Returns a new instance of AuthError.



154
155
156
157
158
159
# File 'lib/safire/errors.rb', line 154

def initialize(status: nil, error_code: nil, error_description: nil)
  @status            = status
  @error_code        = error_code
  @error_description = error_description
  super(build_message)
end

Instance Attribute Details

#error_codeString? (readonly)

Returns OAuth2 error field.

Returns:

  • (String, nil)

    OAuth2 error field



151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/safire/errors.rb', line 151

class AuthError < Error
  attr_reader :status, :error_code, :error_description

  def initialize(status: nil, error_code: nil, error_description: nil)
    @status            = status
    @error_code        = error_code
    @error_description = error_description
    super(build_message)
  end

  private

  def build_message
    parts = ['Authorization request failed']
    parts << "HTTP #{@status}" if @status
    parts << @error_code if @error_code
    parts << @error_description if @error_description
    parts.join('')
  end
end

#error_descriptionString? (readonly)

Returns OAuth2 error_description field.

Returns:

  • (String, nil)

    OAuth2 error_description field



151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/safire/errors.rb', line 151

class AuthError < Error
  attr_reader :status, :error_code, :error_description

  def initialize(status: nil, error_code: nil, error_description: nil)
    @status            = status
    @error_code        = error_code
    @error_description = error_description
    super(build_message)
  end

  private

  def build_message
    parts = ['Authorization request failed']
    parts << "HTTP #{@status}" if @status
    parts << @error_code if @error_code
    parts << @error_description if @error_description
    parts.join('')
  end
end

#statusInteger? (readonly)

Returns HTTP status code.

Returns:

  • (Integer, nil)

    HTTP status code



151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/safire/errors.rb', line 151

class AuthError < Error
  attr_reader :status, :error_code, :error_description

  def initialize(status: nil, error_code: nil, error_description: nil)
    @status            = status
    @error_code        = error_code
    @error_description = error_description
    super(build_message)
  end

  private

  def build_message
    parts = ['Authorization request failed']
    parts << "HTTP #{@status}" if @status
    parts << @error_code if @error_code
    parts << @error_description if @error_description
    parts.join('')
  end
end