Skip to content

Commit 48b2993

Browse files
authored
Merge pull request #698 from esposito/patch-1
Fix raise signature for Ruby < 3.2
2 parents e7d88f5 + e0e6038 commit 48b2993

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

lib/spring/application.rb

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -302,13 +302,26 @@ def shush_backtraces
302302
Kernel.module_eval do
303303
old_raise = Kernel.method(:raise)
304304
remove_method :raise
305-
define_method :raise do |*args, **kwargs|
306-
begin
307-
old_raise.call(*args, **kwargs)
308-
ensure
309-
if $!
310-
lib = File.expand_path("..", __FILE__)
311-
$!.backtrace.reject! { |line| line.start_with?(lib) } unless $!.backtrace.frozen?
305+
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.2.0')
306+
define_method :raise do |*args, **kwargs|
307+
begin
308+
old_raise.call(*args, **kwargs)
309+
ensure
310+
if $!
311+
lib = File.expand_path("..", __FILE__)
312+
$!.backtrace.reject! { |line| line.start_with?(lib) } unless $!.backtrace.frozen?
313+
end
314+
end
315+
end
316+
else
317+
define_method :raise do |*args|
318+
begin
319+
old_raise.call(*args)
320+
ensure
321+
if $!
322+
lib = File.expand_path("..", __FILE__)
323+
$!.backtrace.reject! { |line| line.start_with?(lib) } unless $!.backtrace.frozen?
324+
end
312325
end
313326
end
314327
end

0 commit comments

Comments
 (0)