Skip to content

Commit

Permalink
Merge pull request #698 from esposito/patch-1
Browse files Browse the repository at this point in the history
Fix raise signature for Ruby < 3.2
  • Loading branch information
rafaelfranca authored Aug 2, 2023
2 parents e7d88f5 + e0e6038 commit 48b2993
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions lib/spring/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -302,13 +302,26 @@ def shush_backtraces
Kernel.module_eval do
old_raise = Kernel.method(:raise)
remove_method :raise
define_method :raise do |*args, **kwargs|
begin
old_raise.call(*args, **kwargs)
ensure
if $!
lib = File.expand_path("..", __FILE__)
$!.backtrace.reject! { |line| line.start_with?(lib) } unless $!.backtrace.frozen?
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.2.0')
define_method :raise do |*args, **kwargs|
begin
old_raise.call(*args, **kwargs)
ensure
if $!
lib = File.expand_path("..", __FILE__)
$!.backtrace.reject! { |line| line.start_with?(lib) } unless $!.backtrace.frozen?
end
end
end
else
define_method :raise do |*args|
begin
old_raise.call(*args)
ensure
if $!
lib = File.expand_path("..", __FILE__)
$!.backtrace.reject! { |line| line.start_with?(lib) } unless $!.backtrace.frozen?
end
end
end
end
Expand Down

0 comments on commit 48b2993

Please sign in to comment.