sorbet-runtime 0.4.4514 → 0.4.4515
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7927e8b76dd111237a11cb4cc99bfa208b8bb1e8
|
4
|
+
data.tar.gz: 28f2417938066cbda4161e6a8e3910b512dd7349
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db60aae38ecf3e65f54451d591d0ae005e96691bb192ee9a0ff3266e095acdedbe0ebd64af20845fb51258aa85f74775d8ad257d98d1bbce29555dee52212a5f
|
7
|
+
data.tar.gz: 33dab3b182b0d79f5207bd844e3bee839704e6d4d0041760d7c85340efb59cde7b68d4d14173ec815bff559330910829bd9d22fc09579bb42d2542ae931956f3
|
data/lib/types/_types.rb
CHANGED
@@ -184,7 +184,7 @@ module T
|
|
184
184
|
begin
|
185
185
|
raise TypeError.new("Passed `nil` into T.must")
|
186
186
|
rescue TypeError => e # raise into rescue to ensure e.backtrace is populated
|
187
|
-
T::
|
187
|
+
T::Configuration.inline_type_error_handler(e)
|
188
188
|
end
|
189
189
|
end
|
190
190
|
|
@@ -209,7 +209,7 @@ module T
|
|
209
209
|
begin
|
210
210
|
raise TypeError.new(msg)
|
211
211
|
rescue TypeError => e # raise into rescue to ensure e.backtrace is populated
|
212
|
-
T::
|
212
|
+
T::Configuration.inline_type_error_handler(e)
|
213
213
|
end
|
214
214
|
end
|
215
215
|
|
data/lib/types/configuration.rb
CHANGED
@@ -89,6 +89,7 @@ module T::Configuration
|
|
89
89
|
else
|
90
90
|
inline_type_error_handler_default(error)
|
91
91
|
end
|
92
|
+
nil
|
92
93
|
end
|
93
94
|
|
94
95
|
# Set a handler to handle errors that occur when the builder methods in the
|
@@ -128,6 +129,7 @@ module T::Configuration
|
|
128
129
|
else
|
129
130
|
sig_builder_error_handler_default(error, location)
|
130
131
|
end
|
132
|
+
nil
|
131
133
|
end
|
132
134
|
|
133
135
|
# Set a handler to handle sig validation errors.
|
@@ -171,12 +173,13 @@ module T::Configuration
|
|
171
173
|
raise error
|
172
174
|
end
|
173
175
|
|
174
|
-
def self.sig_validation_error_handler(error, opts)
|
176
|
+
def self.sig_validation_error_handler(error, opts={})
|
175
177
|
if @sig_validation_error_handler
|
176
178
|
@sig_validation_error_handler.call(error, opts)
|
177
179
|
else
|
178
180
|
sig_validation_error_handler_default(error, opts)
|
179
181
|
end
|
182
|
+
nil
|
180
183
|
end
|
181
184
|
|
182
185
|
# Set a handler for type errors that result from calling a method.
|
@@ -216,12 +219,13 @@ module T::Configuration
|
|
216
219
|
raise TypeError.new(opts[:pretty_message])
|
217
220
|
end
|
218
221
|
|
219
|
-
def self.call_validation_error_handler(signature, opts)
|
222
|
+
def self.call_validation_error_handler(signature, opts={})
|
220
223
|
if @call_validation_error_handler
|
221
224
|
@call_validation_error_handler.call(signature, opts)
|
222
225
|
else
|
223
226
|
call_validation_error_handler_default(signature, opts)
|
224
227
|
end
|
228
|
+
nil
|
225
229
|
end
|
226
230
|
|
227
231
|
# Set a handler for logging
|
data/lib/types/private/casts.rb
CHANGED
@@ -14,7 +14,7 @@ module T::Private
|
|
14
14
|
|
15
15
|
raise TypeError.new("#{cast_method}: #{error}\n#{suffix}")
|
16
16
|
rescue TypeError => e # raise into rescue to ensure e.backtrace is populated
|
17
|
-
T::
|
17
|
+
T::Configuration.inline_type_error_handler(e)
|
18
18
|
value
|
19
19
|
end
|
20
20
|
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# typed: true
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
module T::Private::ErrorHandler
|
5
|
-
# Handle a rescued TypeError. This will pass the TypeError to the
|
6
|
-
# T::Configuration.inline_type_error_handler so that the user can override
|
7
|
-
# error handling if they wish. If no inline_type_error_handler is set, this
|
8
|
-
# method will call handle_inline_type_error_default, which raises the error.
|
9
|
-
def self.handle_inline_type_error(type_error)
|
10
|
-
T::Configuration.inline_type_error_handler(type_error)
|
11
|
-
nil
|
12
|
-
end
|
13
|
-
|
14
|
-
# Handle a sig declaration failure. This allows users to override the behavior
|
15
|
-
# when a sig decl fails. If T::Configuration.sig_builder_error_handler
|
16
|
-
# is unset, this method will call handle_sig_builder_error_default.
|
17
|
-
def self.handle_sig_builder_error(error, location)
|
18
|
-
T::Configuration.sig_builder_error_handler(error, location)
|
19
|
-
nil
|
20
|
-
end
|
21
|
-
|
22
|
-
# Handle a sig build validation failure. This allows users to override the
|
23
|
-
# behavior when a sig build fails. If T::Configuration.sig_validation_error_handler
|
24
|
-
# is unset, this method will call handle_sig_validation_error_default.
|
25
|
-
def self.handle_sig_validation_error(error, opts={})
|
26
|
-
T::Configuration.sig_validation_error_handler(error, opts)
|
27
|
-
nil
|
28
|
-
end
|
29
|
-
|
30
|
-
# Handle a sig call validation failure. This allows users to override the
|
31
|
-
# behavior when a sig call fails. If T::Configuration.call_validation_error_handler
|
32
|
-
# is unset, this method will call handle_call_validation_error_default.
|
33
|
-
def self.handle_call_validation_error(signature, opts={})
|
34
|
-
T::Configuration.call_validation_error_handler(signature, opts)
|
35
|
-
nil
|
36
|
-
end
|
37
|
-
end
|
@@ -256,7 +256,7 @@ module T::Private::Methods
|
|
256
256
|
begin
|
257
257
|
run_builder(declaration_block)
|
258
258
|
rescue DeclBuilder::BuilderError => e
|
259
|
-
T::
|
259
|
+
T::Configuration.sig_builder_error_handler(e, declaration_block.loc)
|
260
260
|
nil
|
261
261
|
end
|
262
262
|
|
@@ -312,7 +312,7 @@ module T::Private::Methods
|
|
312
312
|
super_method = original_method&.super_method
|
313
313
|
super_signature = signature_for_method(super_method) if super_method
|
314
314
|
|
315
|
-
T::
|
315
|
+
T::Configuration.sig_validation_error_handler(
|
316
316
|
e,
|
317
317
|
method: original_method,
|
318
318
|
declaration: current_declaration,
|
@@ -1162,7 +1162,7 @@ module T::Private::Methods::CallValidation
|
|
1162
1162
|
"Caller: #{caller_loc.path}:#{caller_loc.lineno}\n" \
|
1163
1163
|
"Definition: #{definition_file}:#{definition_line}"
|
1164
1164
|
|
1165
|
-
T::
|
1165
|
+
T::Configuration.call_validation_error_handler(
|
1166
1166
|
method_sig,
|
1167
1167
|
message: error_message,
|
1168
1168
|
pretty_message: pretty_message,
|