artirix_data_models 0.14.0 → 0.14.1
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: 46351acd75da3e9389df085d1ac1f2c0650b8170
|
4
|
+
data.tar.gz: dbc025033b44bafb353808a79677a0cd26f1d168
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e0688236b185df19b6b5aeec4ea71c96b3a13a00781db5e53d40961705e0ca19eb9d6451418641dfe970c2b72d9035ba9d1bddb4aa9e02c395c10158dfe4d7b
|
7
|
+
data.tar.gz: 6cf4baac1f99bc41780b602a1ea7f8c0ec52217d1c6b7dec026e79c9f8bd48a0d1687b5bffc9c7742b3414fd880f4e4c24d46657f5bf60fe083762df2549aac7
|
data/README.md
CHANGED
@@ -268,6 +268,18 @@ end
|
|
268
268
|
|
269
269
|
## Changes
|
270
270
|
|
271
|
+
### 0.14.1
|
272
|
+
- Exceptions now with `data_hash` and ability to be raised with message, options, or both.
|
273
|
+
- Cache Adaptors now store the data hash of the NotFound exception, and a new one is built and raised when reading a cached NotFound.
|
274
|
+
|
275
|
+
```ruby
|
276
|
+
raise ArtirixDataModels::DataGateway::NotFound, 'blah blah'
|
277
|
+
raise ArtirixDataModels::DataGateway::NotFound, path: 'something', message: 'blah blah'
|
278
|
+
raise ArtirixDataModels::DataGateway::NotFound.new('xxx')
|
279
|
+
raise ArtirixDataModels::DataGateway::NotFound.new(path: 'x')
|
280
|
+
raise ArtirixDataModels::DataGateway::NotFound.new('Something', path: 'x')
|
281
|
+
```
|
282
|
+
|
271
283
|
### 0.14.0
|
272
284
|
- `Model`: added static `mark_full_mode_by_default`: if called in the model definition it will make all new models full mode by default
|
273
285
|
|
@@ -68,7 +68,7 @@ class ArtirixDataModels::CachedActionAdaptor
|
|
68
68
|
cache_result [STATUS_OK, result]
|
69
69
|
result
|
70
70
|
rescue ArtirixDataModels::DataGateway::NotFound => e
|
71
|
-
cache_result [STATUS_NOT_FOUND, e.
|
71
|
+
cache_result [STATUS_NOT_FOUND, e.data_hash]
|
72
72
|
raise e
|
73
73
|
end
|
74
74
|
|
@@ -74,7 +74,10 @@ class ArtirixDataModels::DataGateway
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
rescue Faraday::ConnectionFailed => e
|
77
|
-
raise ConnectionError
|
77
|
+
raise ConnectionError,
|
78
|
+
path: path,
|
79
|
+
method: method,
|
80
|
+
message: "method: #{method}, path: #{path}, error: #{e}"
|
78
81
|
end
|
79
82
|
|
80
83
|
def body_to_json(body)
|
@@ -100,7 +103,11 @@ class ArtirixDataModels::DataGateway
|
|
100
103
|
end
|
101
104
|
|
102
105
|
rescue Oj::ParseError => e
|
103
|
-
raise ParseError
|
106
|
+
raise ParseError,
|
107
|
+
path: path,
|
108
|
+
method: method,
|
109
|
+
response_body: result,
|
110
|
+
message: e.message
|
104
111
|
end
|
105
112
|
|
106
113
|
#######################
|
@@ -119,7 +126,11 @@ class ArtirixDataModels::DataGateway
|
|
119
126
|
return response.body if response.success?
|
120
127
|
|
121
128
|
klass = exception_for_status(response.status)
|
122
|
-
raise klass
|
129
|
+
raise klass,
|
130
|
+
path: path,
|
131
|
+
method: method,
|
132
|
+
response_body: response.body,
|
133
|
+
response_status: response.status
|
123
134
|
end
|
124
135
|
|
125
136
|
def self.exception_for_status(response_status)
|
@@ -183,13 +194,37 @@ class ArtirixDataModels::DataGateway
|
|
183
194
|
end
|
184
195
|
|
185
196
|
class Error < StandardError
|
186
|
-
attr_reader :path, :method, :response_status, :response_body
|
197
|
+
attr_reader :path, :method, :response_status, :response_body, :message
|
198
|
+
|
199
|
+
alias_method :msg, :message
|
200
|
+
|
201
|
+
def initialize(*args)
|
202
|
+
case args.size
|
203
|
+
when 0
|
204
|
+
message = nil
|
205
|
+
options = {}
|
206
|
+
when 1
|
207
|
+
if args.first.kind_of? Hash
|
208
|
+
options = args.first
|
209
|
+
message = nil
|
210
|
+
else
|
211
|
+
message = args.first
|
212
|
+
options = {}
|
213
|
+
end
|
214
|
+
else
|
215
|
+
message = args[0]
|
216
|
+
options = args[1]
|
187
217
|
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
218
|
+
if message.kind_of? Hash
|
219
|
+
options, message = message, options
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
if message.present?
|
224
|
+
options[:message] = message
|
225
|
+
end
|
226
|
+
|
227
|
+
build_from_options(options) if options.present?
|
193
228
|
end
|
194
229
|
|
195
230
|
def json_response_body
|
@@ -210,11 +245,37 @@ class ArtirixDataModels::DataGateway
|
|
210
245
|
method: method,
|
211
246
|
response_status: response_status,
|
212
247
|
response_body: response_body,
|
213
|
-
message:
|
248
|
+
message: message,
|
214
249
|
}.select { |_, v| v.present? }.map { |k, v| "#{k}: #{v.inspect}" }
|
215
250
|
|
216
251
|
"#{self.class}: #{parts.join ', '}"
|
217
252
|
end
|
253
|
+
|
254
|
+
def data_hash
|
255
|
+
{
|
256
|
+
class: self.class.to_s,
|
257
|
+
path: path,
|
258
|
+
method: method,
|
259
|
+
response_status: response_status,
|
260
|
+
response_body: response_body,
|
261
|
+
message: message,
|
262
|
+
}
|
263
|
+
end
|
264
|
+
|
265
|
+
# for testing
|
266
|
+
def matches?(other)
|
267
|
+
other.kind_of? self.class
|
268
|
+
end
|
269
|
+
|
270
|
+
private
|
271
|
+
|
272
|
+
def build_from_options(path: nil, method: nil, response_status: nil, response_body: nil, message: nil, **_other)
|
273
|
+
@path = path
|
274
|
+
@method = method
|
275
|
+
@response_status = response_status
|
276
|
+
@response_body = response_body
|
277
|
+
@message = message.presence || self.class.to_s
|
278
|
+
end
|
218
279
|
end
|
219
280
|
|
220
281
|
class ParseError < Error
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: artirix_data_models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.14.
|
4
|
+
version: 0.14.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eduardo Turiño
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|