Skip to content

Match Exception#full_message with MRI 3.2#8040

Merged
enebo merged 2 commits intojruby:masterfrom
ntkme:mri-exception-format
Dec 11, 2023
Merged

Match Exception#full_message with MRI 3.2#8040
enebo merged 2 commits intojruby:masterfrom
ntkme:mri-exception-format

Conversation

@ntkme
Copy link
Contributor

@ntkme ntkme commented Dec 9, 2023

In my very limited test, this should matches MRI 3.2's formatting at byte level as long as the backtrace is exactly the same. E.g. rescue then re-raise a different error creates an additional line in backtrace for MRI, but not in jruby - the output will be slightly different in such case.

Why match MRI 3.2 not 3.1? The only difference between 3.1 and 3.2 is how order: works. In 3.2, order default to :top, which is the same as the current jruby behavior. Therefore, matching 3.2 is actually a smaller change than matching 3.1.

@ntkme
Copy link
Contributor Author

ntkme commented Dec 9, 2023

This is the limit test I did:

diff <(ruby test.rb) <(./bin/jruby test.rb)
diff <(ruby test.rb 2>/dev/null) <(./bin/jruby test.rb 2>/dev/null)

Test script:

def recurse(depth, limit)
  if depth < limit
    recurse(depth + 1, limit)
  else
    raise 'limit reached'
  end
end

begin
  recurse(0, 10)
rescue => e
  puts e.full_message
  puts '---'
  puts e.full_message(highlight: nil)
  puts '---'
  puts e.full_message(order: nil)
  puts '---'
  puts e.full_message(highlight: nil, order: nil)
  puts '---'
  puts e.full_message(highlight: nil, order: :top)
  puts '---'
  puts e.full_message(highlight: nil, order: :bottom)
  puts '---'
  puts e.full_message(highlight: false, order: nil)
  puts '---'
  puts e.full_message(highlight: false, order: :top)
  puts '---'
  puts e.full_message(highlight: false, order: :bottom)
  puts '---'
  puts e.full_message(highlight: true, order: nil)
  puts '---'
  puts e.full_message(highlight: true, order: :top)
  puts '---'
  puts e.full_message(highlight: true, order: :bottom)
end

@enebo enebo added this to the JRuby 9.4.6.0 milestone Dec 10, 2023
@enebo enebo merged commit 627d8d1 into jruby:master Dec 11, 2023
@enebo
Copy link
Member

enebo commented Dec 11, 2023

@ntkme cool. If someone opens an issue about order being wrong then we can reconsider whether we should change it but the fact it has changed in 3.2 means people should not depend on order default anyways.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants