Exception: HumanError::Errors::ResourcePersistenceError
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- HumanError::Errors::ResourcePersistenceError
- Includes:
- HumanError::Error, CrudError
- Defined in:
- lib/human_error/errors/crud_errors/resource_persistence_error.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#errors ⇒ Object
Returns the value of attribute errors.
Attributes included from CrudError
#action, #resource_id, #resource_name
Attributes included from HumanError::Error
#code, #developer_documentation_url, #external_documentation_url, #id, #message
Class Method Summary collapse
Instance Method Summary collapse
Methods included from CrudError
Methods included from HumanError::Error
#as_json, included, #initialize, #to_json, #to_s
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
9 10 11 |
# File 'lib/human_error/errors/crud_errors/resource_persistence_error.rb', line 9 def attributes @attributes end |
#errors ⇒ Object
Returns the value of attribute errors.
9 10 11 |
# File 'lib/human_error/errors/crud_errors/resource_persistence_error.rb', line 9 def errors @errors end |
Class Method Details
.convert(original_error, overrides = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/human_error/errors/crud_errors/resource_persistence_error.rb', line 12 def self.convert(original_error, overrides = {}) initialization_parameters = {} case original_error.class.name when 'ActiveRecord::RecordInvalid', 'ActiveRecord::RecordNotSaved' initialization_parameters = { attributes: original_error.record.attributes, errors: original_error.record.errors., } end new(initialization_parameters.merge(overrides)) end |
Instance Method Details
#detail ⇒ Object
36 37 38 39 |
# File 'lib/human_error/errors/crud_errors/resource_persistence_error.rb', line 36 def detail "One or more of the attributes on the #{resource_name} you attempted " \ "to #{action} is invalid." end |
#http_status ⇒ Object
28 29 30 |
# File 'lib/human_error/errors/crud_errors/resource_persistence_error.rb', line 28 def http_status 422 end |
#source ⇒ Object
41 42 43 44 45 46 |
# File 'lib/human_error/errors/crud_errors/resource_persistence_error.rb', line 41 def source { 'errors' => errors, 'attributes' => attributes, } end |
#title ⇒ Object
32 33 34 |
# File 'lib/human_error/errors/crud_errors/resource_persistence_error.rb', line 32 def title 'Resource Persistence Error' end |