Exception: HumanError::Errors::ForbiddenError
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- HumanError::Errors::ForbiddenError
- Includes:
- HumanError::Error, AuthorizationError
- Defined in:
- lib/human_error/errors/authorization_errors/forbidden_error.rb
Constant Summary collapse
- NON_SPECIFIC_RESOURCE_ACTIONS =
%w{index create}.freeze
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#resource_id ⇒ Object
Returns the value of attribute resource_id.
-
#resource_name ⇒ Object
Returns the value of attribute resource_name.
Attributes included from HumanError::Error
#code, #developer_documentation_url, #external_documentation_url, #id, #message
Instance Method Summary collapse
Methods included from HumanError::Error
#as_json, included, #initialize, #to_json, #to_s
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
11 12 13 |
# File 'lib/human_error/errors/authorization_errors/forbidden_error.rb', line 11 def action @action end |
#resource_id ⇒ Object
Returns the value of attribute resource_id.
11 12 13 |
# File 'lib/human_error/errors/authorization_errors/forbidden_error.rb', line 11 def resource_id @resource_id end |
#resource_name ⇒ Object
Returns the value of attribute resource_name.
11 12 13 |
# File 'lib/human_error/errors/authorization_errors/forbidden_error.rb', line 11 def resource_name @resource_name end |
Instance Method Details
#detail ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/human_error/errors/authorization_errors/forbidden_error.rb', line 23 def detail detail_quantity = if NON_SPECIFIC_RESOURCE_ACTIONS.include? action.to_s "#{action} a #{resource_name}" else "#{action} the #{resource_name} with ID #{resource_id}" end "You do not have access to #{detail_quantity}. Providing a different set of " \ 'credentials may potentially allow you access to this resource.' end |
#http_status ⇒ Object
15 16 17 |
# File 'lib/human_error/errors/authorization_errors/forbidden_error.rb', line 15 def http_status 403 end |
#source ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/human_error/errors/authorization_errors/forbidden_error.rb', line 34 def source @source ||= { 'resource_name' => resource_name, 'resource_id' => resource_id, 'action' => @action, } end |
#title ⇒ Object
19 20 21 |
# File 'lib/human_error/errors/authorization_errors/forbidden_error.rb', line 19 def title 'Forbidden' end |