Exception: Rack::OAuth2::Server::Abstract::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/rack/oauth2/server/abstract/error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status, error, description = nil, options = {}) ⇒ Error

Returns a new instance of Error.



8
9
10
11
12
13
14
15
# File 'lib/rack/oauth2/server/abstract/error.rb', line 8

def initialize(status, error, description = nil, options = {})
  @status      = status
  @error       = error
  @description = description
  @uri         = options[:uri]
  @realm       = options[:realm]
  super [error, description].compact.join(' :: ')
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



6
7
8
# File 'lib/rack/oauth2/server/abstract/error.rb', line 6

def description
  @description
end

#errorObject

Returns the value of attribute error.



6
7
8
# File 'lib/rack/oauth2/server/abstract/error.rb', line 6

def error
  @error
end

#realmObject

Returns the value of attribute realm.



6
7
8
# File 'lib/rack/oauth2/server/abstract/error.rb', line 6

def realm
  @realm
end

#statusObject

Returns the value of attribute status.



6
7
8
# File 'lib/rack/oauth2/server/abstract/error.rb', line 6

def status
  @status
end

#uriObject

Returns the value of attribute uri.



6
7
8
# File 'lib/rack/oauth2/server/abstract/error.rb', line 6

def uri
  @uri
end

Instance Method Details

#finish {|response| ... } ⇒ Object

Yields:

  • (response)


25
26
27
28
29
30
31
32
33
34
# File 'lib/rack/oauth2/server/abstract/error.rb', line 25

def finish
  response = Rack::Response.new
  response.status = status
  yield response if block_given?
  unless response.redirect?
    response.headers['Content-Type'] = 'application/json'
    response.write Util.compact_hash(protocol_params).to_json
  end
  response.finish
end

#protocol_paramsObject



17
18
19
20
21
22
23
# File 'lib/rack/oauth2/server/abstract/error.rb', line 17

def protocol_params
  {
    error:             error,
    error_description: description,
    error_uri:         uri
  }
end