Skip to content

Commit 1b64490

Browse files
committed
Exception#full_message should default the order to :top since Ruby 3
1 parent bc9398c commit 1b64490

File tree

4 files changed

+6
-8
lines changed

4 files changed

+6
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Bug fixes:
1212
Compatibility:
1313

1414
* Fix `Marshal.dump` to raise an error when an object has singleton methods (@bjfish).
15+
* `Exception#full_message` now defaults the order to `:top` like CRuby 3+ (@eregon).
1516

1617
Performance:
1718

src/main/ruby/truffleruby/core/exception.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def inspect
8787
end
8888
end
8989

90-
def full_message(highlight: nil, order: undefined)
90+
def full_message(highlight: nil, order: :top)
9191
Truffle::ExceptionOperations.full_message(self, highlight, order)
9292
end
9393

src/main/ruby/truffleruby/core/truffle/exception_operations.rb

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,9 @@ def self.full_message(exception, highlight, order)
127127
raise ArgumentError, "expected true of false as highlight: #{highlight}" unless highlight.equal?(true) || highlight.equal?(false)
128128
!highlight.equal?(false)
129129
end
130-
reverse = if Primitive.undefined?(order)
131-
Exception.to_tty?
132-
else
133-
raise ArgumentError, "expected :top or :bottom as order: #{order}" unless order.equal?(:top) || order.equal?(:bottom)
134-
!order.equal?(:top)
135-
end
130+
131+
raise ArgumentError, "expected :top or :bottom as order: #{order}" unless order.equal?(:top) || order.equal?(:bottom)
132+
reverse = !order.equal?(:top)
136133

137134
result = ''.b
138135
bt = exception.backtrace || caller(2)

src/main/ruby/truffleruby/core/truffle/thread_operations.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def self.detect_outermost_recursion(obj, &block)
161161
end
162162

163163
def self.report_exception(thread, exception)
164-
message = "#{thread.inspect} terminated with exception:\n#{exception.full_message}"
164+
message = "#{thread.inspect} terminated with exception (report_on_exception is true):\n#{exception.full_message}"
165165
$stderr.write message
166166
end
167167

0 commit comments

Comments
 (0)