Exception: Garage::Unauthorized

Inherits:
HTTPError
  • Object
show all
Defined in:
lib/garage/exceptions.rb

Direct Known Subclasses

MissingScopeError, PermissionError

Instance Attribute Summary collapse

Attributes inherited from HTTPError

#status

Instance Method Summary collapse

Methods inherited from HTTPError

#status_code

Constructor Details

#initialize(user, action, resource_class, status = :forbidden, scopes = []) ⇒ Unauthorized

Returns a new instance of Unauthorized.



19
20
21
22
23
24
25
26
27
# File 'lib/garage/exceptions.rb', line 19

def initialize(user, action, resource_class, status = :forbidden, scopes = [])
  @user, @action, @resource_class, @status, @scopes = user, action, resource_class, status, scopes

  if scopes.empty?
    super "Authorized user is not allowed to take the requested operation #{action} on #{resource_class}"
  else
    super "Insufficient scope to process the requested operation. Missing scope(s): #{scopes.join(", ")}"
  end
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



17
18
19
# File 'lib/garage/exceptions.rb', line 17

def action
  @action
end

#resource_classObject (readonly)

Returns the value of attribute resource_class.



17
18
19
# File 'lib/garage/exceptions.rb', line 17

def resource_class
  @resource_class
end

#scopesObject (readonly)

Returns the value of attribute scopes.



17
18
19
# File 'lib/garage/exceptions.rb', line 17

def scopes
  @scopes
end

#userObject (readonly)

Returns the value of attribute user.



17
18
19
# File 'lib/garage/exceptions.rb', line 17

def user
  @user
end