human_error 1.10.0 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf40c658d11ca2608a07837a6722d0b5ae682e53
|
4
|
+
data.tar.gz: 3c7424f0017c0e6377746a76565537dcbd547488
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c73a0ecc4dfaaf4648bb280dbc8d6752e6ed177fa9e3ec78c538b04c0a75aa3c79f159e9715983f616731e39a100d6cbc4c1b593145da7f9269fcf56a40ca14b
|
7
|
+
data.tar.gz: 6d537388cdb3f30173203336de4a45cffb809221c7095fbfe73f49af43d1aa095cb93c807a48a1150819eab20a5651aeb0dd827741fe290231930d019ca2a5bd
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'human_error/errors/crud_errors/resource_persistence_error'
|
2
|
+
require 'human_error/errors/crud_errors/resource_not_found_error'
|
3
|
+
require 'human_error/errors/crud_errors/association_error'
|
4
|
+
|
5
|
+
class HumanError
|
6
|
+
module RescuableResource
|
7
|
+
module ClassMethods
|
8
|
+
def rescue_resource(resource_name, from:, via:)
|
9
|
+
lookup_library = via
|
10
|
+
|
11
|
+
if from.include? 'persistence'
|
12
|
+
rescue_from HumanError::Errors::ResourcePersistenceError do |e|
|
13
|
+
error = lookup_library.fetch(
|
14
|
+
'ResourcePersistenceError',
|
15
|
+
resource_name: e.resource_name,
|
16
|
+
attributes: e.attributes,
|
17
|
+
errors: e.errors,
|
18
|
+
action: action_name)
|
19
|
+
|
20
|
+
render json: error,
|
21
|
+
status: error.http_status
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
if from.include? 'not_found'
|
26
|
+
rescue_from HumanError::Errors::ResourceNotFoundError do |e|
|
27
|
+
error = lookup_library.fetch(
|
28
|
+
'ResourceNotFoundError',
|
29
|
+
resource_name: e.resource_name,
|
30
|
+
resource_id: e.resource_id,
|
31
|
+
action: action_name)
|
32
|
+
|
33
|
+
render json: error,
|
34
|
+
status: error.http_status
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
if from.include? 'association'
|
39
|
+
rescue_from HumanError::Errors::AssociationError do |e|
|
40
|
+
error = lookup_library.fetch(
|
41
|
+
'AssociationError',
|
42
|
+
resource_name: e.resource_name,
|
43
|
+
association_name: e.association_name,
|
44
|
+
association_id: e.association_id,
|
45
|
+
attributes: e.attributes)
|
46
|
+
|
47
|
+
render json: error,
|
48
|
+
status: error.http_status
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.included(base)
|
55
|
+
base.extend ClassMethods
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/lib/human_error/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: human_error
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jfelchner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -77,6 +77,7 @@ files:
|
|
77
77
|
- lib/human_error/errors/request_error.rb
|
78
78
|
- lib/human_error/knowledgebase_id_directory.rb
|
79
79
|
- lib/human_error/persistable.rb
|
80
|
+
- lib/human_error/rescuable_resource.rb
|
80
81
|
- lib/human_error/utilities/string.rb
|
81
82
|
- lib/human_error/version.rb
|
82
83
|
- spec/lib/human_error/configuration_spec.rb
|
@@ -88,6 +89,7 @@ files:
|
|
88
89
|
- spec/lib/human_error/errors/crud_errors/resource_not_found_error_spec.rb
|
89
90
|
- spec/lib/human_error/errors/crud_errors/resource_persistence_error_spec.rb
|
90
91
|
- spec/lib/human_error/errors/request_error_spec.rb
|
92
|
+
- spec/lib/human_error/rescuable_resource_spec.rb
|
91
93
|
- spec/lib/human_error_spec.rb
|
92
94
|
homepage: https://github.com/thekompanee/human_error
|
93
95
|
licenses: []
|
@@ -109,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
111
|
version: '0'
|
110
112
|
requirements: []
|
111
113
|
rubyforge_project: human_error
|
112
|
-
rubygems_version: 2.
|
114
|
+
rubygems_version: 2.3.0
|
113
115
|
signing_key:
|
114
116
|
specification_version: 4
|
115
117
|
summary: Common Error Extensions and Helpers
|
@@ -123,5 +125,6 @@ test_files:
|
|
123
125
|
- spec/lib/human_error/errors/crud_errors/resource_not_found_error_spec.rb
|
124
126
|
- spec/lib/human_error/errors/crud_errors/resource_persistence_error_spec.rb
|
125
127
|
- spec/lib/human_error/errors/request_error_spec.rb
|
128
|
+
- spec/lib/human_error/rescuable_resource_spec.rb
|
126
129
|
- spec/lib/human_error_spec.rb
|
127
130
|
has_rdoc:
|