Exception: FunWithJsonApi::Exceptions::UnauthorizedResource

Inherits:
FunWithJsonApi::Exception show all
Defined in:
lib/fun_with_json_api/exceptions/unauthorized_resource.rb

Overview

Indicates a Resource or Collection item not authorized

Direct Known Subclasses

InvalidResource

Instance Attribute Summary

Attributes inherited from FunWithJsonApi::Exception

#payload

Instance Method Summary collapse

Methods inherited from FunWithJsonApi::Exception

#http_status

Constructor Details

#initialize(message, payload = ExceptionPayload.new) ⇒ UnauthorizedResource

Returns a new instance of UnauthorizedResource.



5
6
7
8
9
10
11
12
13
# File 'lib/fun_with_json_api/exceptions/unauthorized_resource.rb', line 5

def initialize(message, payload = ExceptionPayload.new)
  payload = Array.wrap(payload).each do |unauthorized|
    unauthorized.code ||= 'unauthorized_resource'
    unauthorized.title ||=
      I18n.t('unauthorized_resource', scope: 'fun_with_json_api.exceptions')
    unauthorized.status ||= '403'
  end
  super
end