Exception: JSONAPI::Exceptions::InvalidResource

Inherits:
Error
  • Object
show all
Defined in:
lib/jsonapi/exceptions.rb

Instance Attribute Summary collapse

Attributes inherited from Error

#error_object_overrides

Instance Method Summary collapse

Methods inherited from Error

#create_error_object

Constructor Details

#initialize(resource, error_object_overrides = {}) ⇒ InvalidResource

Returns a new instance of InvalidResource.



73
74
75
76
# File 'lib/jsonapi/exceptions.rb', line 73

def initialize(resource, error_object_overrides = {})
  @resource = resource
  super(error_object_overrides)
end

Instance Attribute Details

#resourceObject

Returns the value of attribute resource.



71
72
73
# File 'lib/jsonapi/exceptions.rb', line 71

def resource
  @resource
end

Instance Method Details

#errorsObject



78
79
80
81
82
83
84
85
# File 'lib/jsonapi/exceptions.rb', line 78

def errors
  [create_error_object(code: JSONAPI::INVALID_RESOURCE,
                       status: :bad_request,
                       title: I18n.t('jsonapi-resources.exceptions.invalid_resource.title',
                                     default: 'Invalid resource'),
                       detail: I18n.t('jsonapi-resources.exceptions.invalid_resource.detail',
                                      default: "#{resource} is not a valid resource.", resource: resource))]
end