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.



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

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

Instance Attribute Details

#resourceObject

Returns the value of attribute resource.



69
70
71
# File 'lib/jsonapi/exceptions.rb', line 69

def resource
  @resource
end

Instance Method Details

#errorsObject



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

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