Exception: HumanError::Errors::ResourceNotFoundError
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- HumanError::Errors::ResourceNotFoundError
show all
- Includes:
- HumanError::Error, CrudError
- Defined in:
- lib/human_error/errors/crud_errors/resource_not_found_error.rb
Instance Attribute Summary
Attributes included from CrudError
#resource_id, #resource_name
#code, #developer_documentation_url, #external_documentation_url, #id, #message
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from CrudError
#initialize
#as_json, included, #initialize, #to_json, #to_s
Class Method Details
.convert(original_error, overrides = {}) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/human_error/errors/crud_errors/resource_not_found_error.rb', line 9
def self.convert(original_error, overrides = {})
initialization_parameters = {}
case original_error.class.name
when 'ActiveRecord::RecordNotFound'
initialization_parameters = {
resource_id: case original_error.message
when /\ACouldn't find .* without an ID\z/
[]
when /\ACouldn't find .* with \'.*\'=([a-f0-9\-]+)/
[Regexp.last_match(1)]
when /\ACouldn't find all .* with \'.*\': ((?:[a-f0-9\-]+(?:, )?)+)/
Array(Regexp.last_match(1).split(', '))
end,
}
end
new(initialization_parameters.merge(overrides))
end
|
Instance Method Details
#action ⇒ Object
46
47
48
|
# File 'lib/human_error/errors/crud_errors/resource_not_found_error.rb', line 46
def action
@action || 'access'
end
|
#detail ⇒ Object
37
38
39
40
|
# File 'lib/human_error/errors/crud_errors/resource_not_found_error.rb', line 37
def detail
"The #{resource_name} you attempted to #{action} for this request is either " \
'not authorized for the authenticated user or does not exist.'
end
|
#http_status ⇒ Object
29
30
31
|
# File 'lib/human_error/errors/crud_errors/resource_not_found_error.rb', line 29
def http_status
404
end
|
#source ⇒ Object
42
43
44
|
# File 'lib/human_error/errors/crud_errors/resource_not_found_error.rb', line 42
def source
{ "#{resource_name_underscored}_id" => resource_id }
end
|
#title ⇒ Object
33
34
35
|
# File 'lib/human_error/errors/crud_errors/resource_not_found_error.rb', line 33
def title
'Resource Not Found'
end
|