convenient_service 0.23.0 → 0.25.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 +4 -4
- data/lib/convenient_service/dependencies/queries/version.rb +18 -0
- data/lib/convenient_service/dependencies/queries.rb +4 -2
- data/lib/convenient_service/extras/rspec.rb +1 -1
- data/lib/convenient_service/logger.rb +6 -3
- data/lib/convenient_service/rspec/matchers/classes/results/base/entities/printers/error/commands/generate_got_jsend_attributes_part.rb +1 -1
- data/lib/convenient_service/rspec/matchers/classes/results/base/entities/printers/failure/commands/generate_got_jsend_attributes_part.rb +1 -1
- data/lib/convenient_service/rspec/matchers/classes/results/base/entities/printers/success/commands/generate_got_jsend_attributes_part.rb +1 -1
- data/lib/convenient_service/rspec/matchers/classes/results/be_error.rb +1 -1
- data/lib/convenient_service/rspec/matchers/classes/results/be_failure.rb +1 -1
- data/lib/convenient_service/rspec/matchers/classes/results/be_not_error.rb +2 -2
- data/lib/convenient_service/rspec/matchers/classes/results/be_not_failure.rb +2 -2
- data/lib/convenient_service/rspec/matchers/classes/results/be_not_success.rb +2 -2
- data/lib/convenient_service/rspec/matchers/classes/results/be_success.rb +1 -1
- data/lib/convenient_service/service/configs/standard.rb +11 -3
- data/lib/convenient_service/service/plugins/can_have_after_step_callbacks/middleware.rb +5 -1
- data/lib/convenient_service/service/plugins/can_have_around_step_callbacks/middleware.rb +1 -1
- data/lib/convenient_service/service/plugins/can_have_before_step_callbacks/middleware.rb +1 -1
- data/lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb +1 -6
- data/lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/scalar.rb +1 -1
- data/lib/convenient_service/service/plugins/{rescues_result_unhandled_exceptions → can_have_formatted_exceptions}/commands/format_backtrace.rb +1 -1
- data/lib/convenient_service/service/plugins/{rescues_result_unhandled_exceptions → can_have_formatted_exceptions}/commands/format_cause.rb +1 -1
- data/lib/convenient_service/service/plugins/{rescues_result_unhandled_exceptions → can_have_formatted_exceptions}/commands/format_class.rb +1 -1
- data/lib/convenient_service/service/plugins/{rescues_result_unhandled_exceptions → can_have_formatted_exceptions}/commands/format_exception.rb +2 -2
- data/lib/convenient_service/service/plugins/{rescues_result_unhandled_exceptions → can_have_formatted_exceptions}/commands/format_line.rb +1 -1
- data/lib/convenient_service/service/plugins/{rescues_result_unhandled_exceptions → can_have_formatted_exceptions}/commands/format_message.rb +1 -1
- data/lib/convenient_service/service/plugins/{rescues_result_unhandled_exceptions → can_have_formatted_exceptions}/constants.rb +1 -1
- data/lib/convenient_service/service/plugins/can_have_formatted_exceptions.rb +35 -0
- data/lib/convenient_service/service/plugins/can_have_handled_exceptions/concern.rb +34 -0
- data/lib/convenient_service/service/plugins/can_have_handled_exceptions.rb +8 -0
- data/lib/convenient_service/service/plugins/can_have_inline_services/concern.rb +29 -0
- data/lib/convenient_service/service/plugins/can_have_inline_services/entities/proxy.rb +205 -0
- data/lib/convenient_service/service/plugins/{can_have_steps/entities/step/plugins/can_be_completed.rb → can_have_inline_services/entities.rb} +1 -1
- data/lib/convenient_service/service/plugins/can_have_inline_services/exceptions.rb +30 -0
- data/lib/convenient_service/service/plugins/can_have_inline_services.rb +36 -0
- data/lib/convenient_service/service/plugins/can_have_sequential_steps/concern.rb +2 -0
- data/lib/convenient_service/service/plugins/can_have_sequential_steps/middleware.rb +1 -5
- data/lib/convenient_service/service/plugins/can_have_steps/concern.rb +1 -6
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/commands/cast_method_factory.rb +5 -8
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/callers/proc.rb +1 -1
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/callers/raw.rb +1 -1
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories/string.rb +1 -1
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/key.rb +1 -1
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/concern/instance_methods.rb +13 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/{can_be_completed → can_be_evaluated}/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_evaluated.rb +8 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_from_exception/concern.rb +4 -4
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_from_handled_exception/concern.rb +81 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_from_handled_exception/exceptions.rb +38 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_from_handled_exception.rb +9 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_from_unhandled_exception/concern.rb +46 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_from_unhandled_exception.rb +8 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins.rb +2 -0
- data/lib/convenient_service/service/plugins/has_j_send_result.rb +84 -0
- data/lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/middleware.rb +3 -3
- data/lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions.rb +0 -2
- data/lib/convenient_service/service/plugins.rb +3 -0
- data/lib/convenient_service/version.rb +1 -1
- data/lib/convenient_service.rb +23 -1
- metadata +24 -11
- /data/lib/convenient_service/service/plugins/{rescues_result_unhandled_exceptions → can_have_formatted_exceptions}/commands.rb +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9a077e3ef95d8ad18dbc79399c5513f29a17491111557cfad7b446eda2bec5a8
|
|
4
|
+
data.tar.gz: 07e8481191d8a8fe51b7995d5507147755ee2676cfe51b9c5a5b11e42f5a47e2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 268d3a56e8ea1e0161dde099762d3d91dcb8c85b005d2fc45e6ab9e8e622a7da15b4c6d70c45809dd8cd83787cbb042ffe71f4aaef369be4562f18d2b6b22340
|
|
7
|
+
data.tar.gz: deeb6b2c67a294a98fee2fdb409d653b4674c83c22f9e8ef413014ef42d1dfe8127e3aaecc85d020a206350607f2276e1f09575f5bb9e0888e4927a73697e513
|
|
@@ -41,6 +41,24 @@ module ConvenientService
|
|
|
41
41
|
false
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
+
##
|
|
45
|
+
# @return [ConvenientService::Dependencies::Queries::Version]
|
|
46
|
+
#
|
|
47
|
+
# @example Beta version is considered as lower than major version.
|
|
48
|
+
# ConvenientService::Dependencies::Queries::Version.new("4.0.0.beta1") >= 4
|
|
49
|
+
# # => false
|
|
50
|
+
#
|
|
51
|
+
# @example That is why there is a way to compare only by the first segment of version.
|
|
52
|
+
# ConvenientService::Dependencies::Queries::Version.new("4.0.0.beta1").major_version >= 4
|
|
53
|
+
# # => true
|
|
54
|
+
#
|
|
55
|
+
# @internal
|
|
56
|
+
# TODO: Add direct specs.
|
|
57
|
+
#
|
|
58
|
+
def major_version
|
|
59
|
+
self.class.new(gem_version&.segments&.first.to_s)
|
|
60
|
+
end
|
|
61
|
+
|
|
44
62
|
##
|
|
45
63
|
# @return [Gem::Version, nil]
|
|
46
64
|
#
|
|
@@ -25,10 +25,12 @@ module ConvenientService
|
|
|
25
25
|
##
|
|
26
26
|
# Returns `true` when Convenient Service is in debug mode. In other words `$CONVENIENT_SERVICE_DEBUG` env variable is set to `true`.
|
|
27
27
|
#
|
|
28
|
-
# @api
|
|
28
|
+
# @api public
|
|
29
29
|
# @since 1.0.0
|
|
30
30
|
# @return [Boolean]
|
|
31
31
|
#
|
|
32
|
+
# @see https://userdocs.convenientservice.org/comprehensive_docs/docs/the_how/how_to_debug_the_convenient_service_lib_itself.html
|
|
33
|
+
#
|
|
32
34
|
def debug?
|
|
33
35
|
::ENV["CONVENIENT_SERVICE_DEBUG"] == "true"
|
|
34
36
|
end
|
|
@@ -499,7 +501,7 @@ module ConvenientService
|
|
|
499
501
|
# @return [Boolean]
|
|
500
502
|
# @note Expected to be called from `spec_helper.rb`.
|
|
501
503
|
#
|
|
502
|
-
def
|
|
504
|
+
def require_rspec_extensions
|
|
503
505
|
require "rspec/expectations"
|
|
504
506
|
require "rspec/matchers"
|
|
505
507
|
require "rspec/mocks"
|
|
@@ -46,10 +46,10 @@ module ConvenientService
|
|
|
46
46
|
def new
|
|
47
47
|
super(::STDOUT).tap do |logger|
|
|
48
48
|
logger.level =
|
|
49
|
-
if ::ENV["
|
|
50
|
-
::Logger::DEBUG
|
|
51
|
-
elsif ::ENV["CONVENIENT_SERVICE_LOGGER_LEVEL"]
|
|
49
|
+
if ::ENV["CONVENIENT_SERVICE_LOGGER_LEVEL"]
|
|
52
50
|
::ENV["CONVENIENT_SERVICE_LOGGER_LEVEL"]
|
|
51
|
+
elsif ::ENV["CONVENIENT_SERVICE_DEBUG"] == "true"
|
|
52
|
+
::Logger::DEBUG
|
|
53
53
|
else
|
|
54
54
|
::Logger::INFO
|
|
55
55
|
end
|
|
@@ -98,6 +98,9 @@ module ConvenientService
|
|
|
98
98
|
##
|
|
99
99
|
# @api public
|
|
100
100
|
#
|
|
101
|
+
# @see https://userdocs.convenientservice.org/comprehensive_docs/docs/the_what/what_is_convenient_service_logger.html
|
|
102
|
+
# @see https://userdocs.convenientservice.org/comprehensive_docs/docs/the_how/how_to_configure_convenient_service_logger.html
|
|
103
|
+
#
|
|
101
104
|
# @internal
|
|
102
105
|
# IMPORTANT: Older versions of `Logger` do NOT support `level` as a string.
|
|
103
106
|
# - https://github.com/ruby/logger/blob/v1.2.8.1/lib/logger.rb#L333
|
|
@@ -90,7 +90,7 @@ module ConvenientService
|
|
|
90
90
|
# @return [String]
|
|
91
91
|
#
|
|
92
92
|
def code_part
|
|
93
|
-
(code == Service::Plugins::HasJSendResult
|
|
93
|
+
(code == Service::Plugins::HasJSendResult.default_error_code) ? "" : "with code `#{code}`"
|
|
94
94
|
end
|
|
95
95
|
|
|
96
96
|
##
|
|
@@ -90,7 +90,7 @@ module ConvenientService
|
|
|
90
90
|
# @return [String]
|
|
91
91
|
#
|
|
92
92
|
def code_part
|
|
93
|
-
(code == Service::Plugins::HasJSendResult
|
|
93
|
+
(code == Service::Plugins::HasJSendResult.default_failure_code) ? "" : "with code `#{code}`"
|
|
94
94
|
end
|
|
95
95
|
|
|
96
96
|
##
|
|
@@ -90,7 +90,7 @@ module ConvenientService
|
|
|
90
90
|
# @return [String]
|
|
91
91
|
#
|
|
92
92
|
def code_part
|
|
93
|
-
(code == Service::Plugins::HasJSendResult
|
|
93
|
+
(code == Service::Plugins::HasJSendResult.default_success_code) ? "" : "with code `#{code}`"
|
|
94
94
|
end
|
|
95
95
|
|
|
96
96
|
##
|
|
@@ -18,8 +18,8 @@ module ConvenientService
|
|
|
18
18
|
#
|
|
19
19
|
def statuses
|
|
20
20
|
[
|
|
21
|
-
Service::Plugins::HasJSendResult
|
|
22
|
-
Service::Plugins::HasJSendResult
|
|
21
|
+
Service::Plugins::HasJSendResult.success_status,
|
|
22
|
+
Service::Plugins::HasJSendResult.failure_status
|
|
23
23
|
]
|
|
24
24
|
end
|
|
25
25
|
end
|
|
@@ -18,8 +18,8 @@ module ConvenientService
|
|
|
18
18
|
#
|
|
19
19
|
def statuses
|
|
20
20
|
[
|
|
21
|
-
Service::Plugins::HasJSendResult
|
|
22
|
-
Service::Plugins::HasJSendResult
|
|
21
|
+
Service::Plugins::HasJSendResult.success_status,
|
|
22
|
+
Service::Plugins::HasJSendResult.error_status
|
|
23
23
|
]
|
|
24
24
|
end
|
|
25
25
|
end
|
|
@@ -18,8 +18,8 @@ module ConvenientService
|
|
|
18
18
|
#
|
|
19
19
|
def statuses
|
|
20
20
|
[
|
|
21
|
-
Service::Plugins::HasJSendResult
|
|
22
|
-
Service::Plugins::HasJSendResult
|
|
21
|
+
Service::Plugins::HasJSendResult.failure_status,
|
|
22
|
+
Service::Plugins::HasJSendResult.error_status
|
|
23
23
|
]
|
|
24
24
|
end
|
|
25
25
|
end
|
|
@@ -94,12 +94,14 @@ module ConvenientService
|
|
|
94
94
|
use ConvenientService::Plugins::Service::CanBeCalled::Concern if options.enabled?(:essential)
|
|
95
95
|
use ConvenientService::Plugins::Common::CanHaveCallbacks::Concern if options.enabled?(:callbacks)
|
|
96
96
|
use ConvenientService::Plugins::Service::CanHaveFallbacks::Concern if options.enabled?(:fallbacks)
|
|
97
|
+
use ConvenientService::Plugins::Service::CanHaveInlineServices::Concern if options.enabled?(:essential)
|
|
97
98
|
use ConvenientService::Plugins::Service::HasInspect::Concern if options.enabled?(:inspect)
|
|
98
99
|
use ConvenientService::Plugins::Service::HasAwesomePrintInspect::Concern if options.enabled?(:awesome_print_inspect)
|
|
99
100
|
use ConvenientService::Plugins::Service::HasAmazingPrintInspect::Concern if options.enabled?(:amazing_print_inspect)
|
|
100
101
|
use ConvenientService::Plugins::Common::CachesConstructorArguments::Concern if options.enabled?(:recalculation)
|
|
101
102
|
use ConvenientService::Plugins::Common::CanBeCopied::Concern if options.enabled?(:recalculation)
|
|
102
103
|
use ConvenientService::Plugins::Service::CanHaveRecalculations::Concern if options.enabled?(:recalculation)
|
|
104
|
+
use ConvenientService::Plugins::Service::CanHaveHandledExceptions::Concern if options.enabled?(:essential)
|
|
103
105
|
use ConvenientService::Plugins::Service::CanNotBeInherited::Concern if options.enabled?(:code_review_automation)
|
|
104
106
|
use ConvenientService::Plugins::Service::HasJSendResultShortSyntax::Concern if options.enabled?(:short_syntax)
|
|
105
107
|
use ConvenientService::Plugins::Service::HasJSendResultStatusCheckShortSyntax::Concern if options.enabled?(:short_syntax)
|
|
@@ -224,7 +226,9 @@ module ConvenientService
|
|
|
224
226
|
use ConvenientService::Plugins::Result::HasPatternMatchingSupport::Concern if options.enabled?(:essential)
|
|
225
227
|
use ConvenientService::Plugins::Result::CanBeFromFallback::Concern if options.enabled?(:fallbacks)
|
|
226
228
|
use ConvenientService::Plugins::Result::CanHaveFallbacks::Concern if options.enabled?(:fallbacks)
|
|
227
|
-
use ConvenientService::Plugins::Result::CanBeFromException::Concern if options.enabled?(:
|
|
229
|
+
use ConvenientService::Plugins::Result::CanBeFromException::Concern if options.enabled?(:essential)
|
|
230
|
+
use ConvenientService::Plugins::Result::CanBeFromHandledException::Concern if options.enabled?(:essential)
|
|
231
|
+
use ConvenientService::Plugins::Result::CanBeFromUnhandledException::Concern if options.enabled?(:fault_tolerance)
|
|
228
232
|
use ConvenientService::Plugins::Result::HasInspect::Concern if options.enabled?(:inspect)
|
|
229
233
|
use ConvenientService::Plugins::Result::HasAwesomePrintInspect::Concern if options.enabled?(:awesome_print_inspect)
|
|
230
234
|
use ConvenientService::Plugins::Result::HasAmazingPrintInspect::Concern if options.enabled?(:amazing_print_inspect)
|
|
@@ -335,7 +339,7 @@ module ConvenientService
|
|
|
335
339
|
concerns do
|
|
336
340
|
use ConvenientService::Plugins::Common::HasInternals::Concern if options.enabled?(:essential)
|
|
337
341
|
use ConvenientService::Plugins::Step::HasResult::Concern if options.enabled?(:essential)
|
|
338
|
-
use ConvenientService::Plugins::Step::
|
|
342
|
+
use ConvenientService::Plugins::Step::CanBeEvaluated::Concern if options.enabled?(:essential)
|
|
339
343
|
use ConvenientService::Plugins::Step::CanBeServiceStep::Concern if options.enabled?(:essential)
|
|
340
344
|
use ConvenientService::Plugins::Step::CanBeMethodStep::Concern if options.enabled?(:essential)
|
|
341
345
|
use ConvenientService::Plugins::Step::CanBeUsedInServiceAwareEnumerables::Concern if options.enabled?(:essential)
|
|
@@ -349,7 +353,6 @@ module ConvenientService
|
|
|
349
353
|
|
|
350
354
|
middlewares :result do
|
|
351
355
|
use ConvenientService::Plugins::Common::CachesReturnValue::Middleware if options.enabled?(:per_instance_caching)
|
|
352
|
-
use ConvenientService::Plugins::Common::CanHaveCallbacks::Middleware if options.enabled?(:callbacks)
|
|
353
356
|
use ConvenientService::Plugins::Step::HasResult::Middleware if options.enabled?(:essential)
|
|
354
357
|
use ConvenientService::Plugins::Step::CanHaveParentResult::Middleware if options.enabled?(:result_parents_trace)
|
|
355
358
|
use ConvenientService::Plugins::Step::CanHaveFallbacks::Middleware.with(fallback_true_status: :failure) if options.enabled?(:fallbacks)
|
|
@@ -366,6 +369,11 @@ module ConvenientService
|
|
|
366
369
|
use ConvenientService::Plugins::Common::CachesReturnValue::Middleware if options.enabled?(:per_instance_caching)
|
|
367
370
|
end
|
|
368
371
|
|
|
372
|
+
middlewares :organizer_result do
|
|
373
|
+
use ConvenientService::Plugins::Common::CachesReturnValue::Middleware if options.enabled?(:per_instance_caching)
|
|
374
|
+
use ConvenientService::Plugins::Common::CanHaveCallbacks::Middleware if options.enabled?(:callbacks)
|
|
375
|
+
end
|
|
376
|
+
|
|
369
377
|
entity :Internals do
|
|
370
378
|
concerns do
|
|
371
379
|
use ConvenientService::Plugins::Internals::HasCache::Concern if options.enabled?(:per_instance_caching)
|
|
@@ -65,11 +65,15 @@ module ConvenientService
|
|
|
65
65
|
# end
|
|
66
66
|
# end
|
|
67
67
|
#
|
|
68
|
+
# @internal
|
|
69
|
+
# IMPORTANT: `result.step.result` does NOT take result from internal cache, it raises instead. That is frustrating to the end-users, but there is NO workaroud yet.
|
|
70
|
+
# TODO: Think about passing `result` with `callback_arguments`. Not perfect, but better than nothing.
|
|
71
|
+
#
|
|
68
72
|
def next(method, **kwargs, &block)
|
|
69
73
|
return chain.next(method, **kwargs, &block) if method != :step
|
|
70
74
|
|
|
71
75
|
entity.step_class.class_exec(kwargs, block) do |kwargs, block|
|
|
72
|
-
after :
|
|
76
|
+
after :organizer_result, **kwargs.merge(source_location: block.source_location) do |result|
|
|
73
77
|
organizer.instance_exec(
|
|
74
78
|
result.step,
|
|
75
79
|
params.to_callback_arguments,
|
|
@@ -73,7 +73,7 @@ module ConvenientService
|
|
|
73
73
|
return chain.next(method, **kwargs, &block) if method != :step
|
|
74
74
|
|
|
75
75
|
entity.step_class.class_exec(kwargs, block) do |kwargs, block|
|
|
76
|
-
around :
|
|
76
|
+
around :organizer_result, **kwargs.merge(source_location: block.source_location) do |chain|
|
|
77
77
|
organizer.instance_exec(
|
|
78
78
|
proc { chain.yield.step },
|
|
79
79
|
params.to_callback_arguments,
|
|
@@ -69,7 +69,7 @@ module ConvenientService
|
|
|
69
69
|
return chain.next(method, **kwargs, &block) if method != :step
|
|
70
70
|
|
|
71
71
|
entity.step_class.class_exec(kwargs, block) do |kwargs, block|
|
|
72
|
-
before :
|
|
72
|
+
before :organizer_result, **kwargs.merge(source_location: block.source_location) do
|
|
73
73
|
organizer.instance_exec(
|
|
74
74
|
params.to_callback_arguments,
|
|
75
75
|
&block
|
|
@@ -23,6 +23,7 @@ module ConvenientService
|
|
|
23
23
|
# @return [ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Base]
|
|
24
24
|
#
|
|
25
25
|
# @note It is NOT recommended to rely on the return value of this method, since it may differ across different `step` related plugins.
|
|
26
|
+
# @see https://userdocs.convenientservice.org/comprehensive_docs/docs/the_what/what_step_input_types_are_available.html
|
|
26
27
|
#
|
|
27
28
|
def step(*args, **kwargs)
|
|
28
29
|
previous_expression = steps.expression
|
|
@@ -717,12 +718,6 @@ module ConvenientService
|
|
|
717
718
|
def steps_result
|
|
718
719
|
::ConvenientService.raise Exceptions::ServiceHasNoSteps.new(service_class: self.class) if steps.none?
|
|
719
720
|
|
|
720
|
-
steps.each_evaluated_step do |step|
|
|
721
|
-
step.save_outputs_in_organizer!
|
|
722
|
-
|
|
723
|
-
step.mark_as_evaluated!
|
|
724
|
-
end
|
|
725
|
-
|
|
726
721
|
steps.result
|
|
727
722
|
end
|
|
728
723
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
module ConvenientService
|
|
9
9
|
module Service
|
|
10
10
|
module Plugins
|
|
11
|
-
module
|
|
11
|
+
module CanHaveFormattedExceptions
|
|
12
12
|
module Commands
|
|
13
13
|
class FormatException < Support::Command
|
|
14
14
|
##
|
|
@@ -49,7 +49,7 @@ module ConvenientService
|
|
|
49
49
|
# @param max_backtrace_size [Integer]
|
|
50
50
|
# @return [void]
|
|
51
51
|
#
|
|
52
|
-
def initialize(exception:, args
|
|
52
|
+
def initialize(exception:, args: [], kwargs: {}, block: nil, max_backtrace_size: Constants::DEFAULT_MAX_BACKTRACE_SIZE)
|
|
53
53
|
@exception = exception
|
|
54
54
|
@args = args
|
|
55
55
|
@kwargs = kwargs
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
##
|
|
4
|
+
# @author Marian Kostyk <mariankostyk13895@gmail.com>
|
|
5
|
+
# @license LGPLv3 <https://www.gnu.org/licenses/lgpl-3.0.html>
|
|
6
|
+
##
|
|
7
|
+
|
|
8
|
+
require_relative "can_have_formatted_exceptions/commands"
|
|
9
|
+
require_relative "can_have_formatted_exceptions/constants"
|
|
10
|
+
|
|
11
|
+
module ConvenientService
|
|
12
|
+
module Service
|
|
13
|
+
module Plugins
|
|
14
|
+
module CanHaveFormattedExceptions
|
|
15
|
+
class << self
|
|
16
|
+
##
|
|
17
|
+
# @return [Integer]
|
|
18
|
+
#
|
|
19
|
+
def default_max_backtrace_size
|
|
20
|
+
Constants::DEFAULT_MAX_BACKTRACE_SIZE
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
##
|
|
24
|
+
# @param exception [StandardError]
|
|
25
|
+
# @param kwargs [Hash{Symbol => Object}]
|
|
26
|
+
# @return [String]
|
|
27
|
+
#
|
|
28
|
+
def format_exception(exception, **kwargs)
|
|
29
|
+
Commands::FormatException.call(exception: exception, **kwargs)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
##
|
|
4
|
+
# @author Marian Kostyk <mariankostyk13895@gmail.com>
|
|
5
|
+
# @license LGPLv3 <https://www.gnu.org/licenses/lgpl-3.0.html>
|
|
6
|
+
##
|
|
7
|
+
|
|
8
|
+
module ConvenientService
|
|
9
|
+
module Service
|
|
10
|
+
module Plugins
|
|
11
|
+
module CanHaveHandledExceptions
|
|
12
|
+
module Concern
|
|
13
|
+
include Support::Concern
|
|
14
|
+
|
|
15
|
+
instance_methods do
|
|
16
|
+
##
|
|
17
|
+
# @api public
|
|
18
|
+
# @param max_backtrace_size [Integer]
|
|
19
|
+
# @return [ConvenientService::Service::Plugins::HasJSendResult::Entities::Result]
|
|
20
|
+
#
|
|
21
|
+
def error_from_exception(exception, max_backtrace_size: Plugins::CanHaveFormattedExceptions.default_max_backtrace_size)
|
|
22
|
+
error(
|
|
23
|
+
data: {handled_exception: exception},
|
|
24
|
+
message: Plugins::CanHaveFormattedExceptions.format_exception(exception, max_backtrace_size: max_backtrace_size),
|
|
25
|
+
code: :handled_exception
|
|
26
|
+
)
|
|
27
|
+
.copy(overrides: {kwargs: {exceptions: {handled: exception}}})
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
##
|
|
4
|
+
# @author Marian Kostyk <mariankostyk13895@gmail.com>
|
|
5
|
+
# @license LGPLv3 <https://www.gnu.org/licenses/lgpl-3.0.html>
|
|
6
|
+
##
|
|
7
|
+
|
|
8
|
+
module ConvenientService
|
|
9
|
+
module Service
|
|
10
|
+
module Plugins
|
|
11
|
+
module CanHaveInlineServices
|
|
12
|
+
module Concern
|
|
13
|
+
include Support::Concern
|
|
14
|
+
|
|
15
|
+
instance_methods do
|
|
16
|
+
##
|
|
17
|
+
# @api private
|
|
18
|
+
# @param block [Proc, nil]
|
|
19
|
+
# @return [ConvenientService::Service::Plugins::CanHaveInlineServices::Entities::Proxy]
|
|
20
|
+
#
|
|
21
|
+
def inline(&block)
|
|
22
|
+
Entities::Proxy.new(&block)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|