Skip to content

Commit fe40a9e

Browse files
committed
Include the meta object name for Exception#full_message with a foreign exception
1 parent 8f70b33 commit fe40a9e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,14 @@ def self.receiver_string(receiver)
9494
def self.message_and_class(exception, highlight)
9595
message = StringValue exception.message.to_s
9696

97+
klass = exception.class.to_s
98+
if Primitive.object_kind_of?(exception, Polyglot::ForeignException) and
99+
Truffle::Interop.has_meta_object?(exception)
100+
klass = "#{klass}: #{Truffle::Interop.meta_qualified_name Truffle::Interop.meta_object(exception)}"
101+
end
102+
97103
if highlight
98-
highlighted_class = " (\e[1;4m#{exception.class}\e[m\e[1m)"
104+
highlighted_class = " (\e[1;4m#{klass}\e[m\e[1m)"
99105
if message.include?("\n")
100106
first = true
101107
result = +''
@@ -113,9 +119,9 @@ def self.message_and_class(exception, highlight)
113119
end
114120
else
115121
if i = message.index("\n")
116-
"#{message[0...i]} (#{exception.class})#{message[i..-1]}"
122+
"#{message[0...i]} (#{klass})#{message[i..-1]}"
117123
else
118-
"#{message} (#{exception.class})"
124+
"#{message} (#{klass})"
119125
end
120126
end
121127
end

0 commit comments

Comments
 (0)