sorbet-runtime 0.5.6380 → 0.5.6389
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e3d0d5bfc5dcb1ca384ecbf66158041b7c083efd63b35de6bc2e17c0eeae517
|
4
|
+
data.tar.gz: 47dd020b8985f5cd5338d4287a3e26f89542428a85bd9bef6f818310dc308c46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8d88ddb272c2823fdd9d9f3e90d9cad2d488cd7a782a919097be4e9fdf2debf0d267c20db241bb67eb074425d9195afc87f8d130913a3addccd6877c881d242
|
7
|
+
data.tar.gz: cafe196e1d9d6097392c2b0d9dc19514b59e572a388ff51b0982f965018a400bce734e777b929193c3f3ff2ea9cdf038ef63b30c8fbfc3a8796e54b1ba8ad828
|
data/lib/types/configuration.rb
CHANGED
@@ -290,51 +290,6 @@ module T::Configuration
|
|
290
290
|
end
|
291
291
|
end
|
292
292
|
|
293
|
-
# Set a handler for deserialization errors
|
294
|
-
#
|
295
|
-
# These generally shouldn't stop execution of the program, but rather inform
|
296
|
-
# some party of the error to action on later.
|
297
|
-
#
|
298
|
-
# @param [Lambda, Proc, Object, nil] value Proc that handles the error
|
299
|
-
# report (pass nil to reset to default behavior)
|
300
|
-
#
|
301
|
-
# Parameters passed to value.call:
|
302
|
-
#
|
303
|
-
# @param [Class] klass The class of the top-level object being deserialized
|
304
|
-
# @param [String] prop_name The name of the prop being deserialized
|
305
|
-
# @param [Object] value The prop value being deserialized
|
306
|
-
# @param [Error] orig_error The original error raised during deserialization
|
307
|
-
#
|
308
|
-
# @example
|
309
|
-
# T::Configuration.deserialization_error_handler = lambda do |klass, prop_name, value, orig_error}
|
310
|
-
# puts "Error deserializing #{prop_name} on #{klass}: #{orig_error.message}
|
311
|
-
# end
|
312
|
-
def self.deserialization_error_handler=(value)
|
313
|
-
validate_lambda_given!(value)
|
314
|
-
@deserialization_error_handler = value
|
315
|
-
end
|
316
|
-
|
317
|
-
private_class_method def self.deserialization_error_handler_default(klass, prop_name, value, orig_error)
|
318
|
-
soft_assert_handler(
|
319
|
-
'Deserialization error (probably unexpected stored type)',
|
320
|
-
storytime: {
|
321
|
-
klass: klass,
|
322
|
-
prop: prop_name,
|
323
|
-
value: value,
|
324
|
-
error: orig_error.message,
|
325
|
-
notify: 'djudd'
|
326
|
-
}
|
327
|
-
)
|
328
|
-
end
|
329
|
-
|
330
|
-
def self.deserialization_error_handler(klass, prop_name, value, orig_error)
|
331
|
-
if @deserialization_error_handler
|
332
|
-
@deserialization_error_handler.call(klass, prop_name, value, orig_error)
|
333
|
-
else
|
334
|
-
deserialization_error_handler_default(klass, prop_name, value, orig_error)
|
335
|
-
end
|
336
|
-
end
|
337
|
-
|
338
293
|
# Set a handler for soft assertions
|
339
294
|
#
|
340
295
|
# These generally shouldn't stop execution of the program, but rather inform
|
@@ -162,7 +162,16 @@ module T::Props
|
|
162
162
|
exceptions.children.each {|c| assert_equal(:const, c.type)}
|
163
163
|
assert_equal(:lvasgn, assignment.type)
|
164
164
|
assert_equal([:e], assignment.children)
|
165
|
-
|
165
|
+
|
166
|
+
deserialization_error, val_return = handler.children
|
167
|
+
|
168
|
+
assert_equal(:send, deserialization_error.type)
|
169
|
+
receiver, method, *args = deserialization_error.children
|
170
|
+
assert_equal(nil, receiver)
|
171
|
+
assert_equal(:raise_deserialization_error, method)
|
172
|
+
args.each {|a| validate_lack_of_side_effects(a, whitelisted_methods_for_deserialize)}
|
173
|
+
|
174
|
+
validate_lack_of_side_effects(val_return, whitelisted_methods_for_deserialize)
|
166
175
|
else
|
167
176
|
validate_lack_of_side_effects(else_body, whitelisted_methods_for_deserialize)
|
168
177
|
end
|
@@ -261,8 +270,7 @@ module T::Props
|
|
261
270
|
private_class_method def self.whitelisted_methods_for_deserialize
|
262
271
|
@whitelisted_methods_for_deserialize ||= {
|
263
272
|
lvar: %i{dup map transform_values transform_keys each_with_object nil? []= to_f},
|
264
|
-
|
265
|
-
const: %i[deserialize from_hash deep_clone_object deserialization_error_handler],
|
273
|
+
const: %i[deserialize from_hash deep_clone_object],
|
266
274
|
}
|
267
275
|
end
|
268
276
|
end
|
@@ -156,6 +156,19 @@ module T::Props::Serializable
|
|
156
156
|
@_required_props_missing_from_deserialize << prop
|
157
157
|
nil
|
158
158
|
end
|
159
|
+
|
160
|
+
private def raise_deserialization_error(prop_name, value, orig_error)
|
161
|
+
T::Configuration.soft_assert_handler(
|
162
|
+
'Deserialization error (probably unexpected stored type)',
|
163
|
+
storytime: {
|
164
|
+
klass: self.class,
|
165
|
+
prop: prop_name,
|
166
|
+
value: value,
|
167
|
+
error: orig_error.message,
|
168
|
+
notify: 'djudd'
|
169
|
+
}
|
170
|
+
)
|
171
|
+
end
|
159
172
|
end
|
160
173
|
|
161
174
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sorbet-runtime
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.6389
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stripe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-04-
|
11
|
+
date: 2021-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|