From aec40d89effa02ffe4cd9307005f33dc5f97e798 Mon Sep 17 00:00:00 2001 From: Abdelkader Boudih Date: Mon, 2 Dec 2024 12:42:37 +0100 Subject: [PATCH] refactor: exception handling in Rescue macro Introduced a constant DEFAULT_EXCEPTIONS to replace inline definition of exceptions. --- lib/trailblazer/macro/rescue.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/trailblazer/macro/rescue.rb b/lib/trailblazer/macro/rescue.rb index 4567bf8..9be5d16 100644 --- a/lib/trailblazer/macro/rescue.rb +++ b/lib/trailblazer/macro/rescue.rb @@ -1,9 +1,10 @@ module Trailblazer module Macro + DEFAULT_EXCEPTIONS = [StandardError].freeze NoopHandler = lambda { |*| } def self.Rescue(*exceptions, handler: NoopHandler, id: Rescue.random_id, &block) - exceptions = [StandardError] unless exceptions.any? + exceptions = DEFAULT_EXCEPTIONS unless exceptions.any? handler = Rescue.deprecate_positional_handler_signature(handler) handler = Trailblazer::Option(handler)