Skip to content

Commit ced6143

Browse files
committed
[GR-17457] Remove extra methods Exception#{backtrace?, location, set_context}
PullRequest: truffleruby/2375
2 parents fad36a7 + d80dfbe commit ced6143

File tree

5 files changed

+13
-28
lines changed

5 files changed

+13
-28
lines changed

spec/tags/truffle/methods_tags.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ fails:Public methods on Digest::Instance should not include finish
3535
fails:Public methods on Digest::Instance should not include to_str
3636
fails:Public methods on Digest::Instance should include block_length
3737
fails:Public methods on Dir should not include closed?
38-
fails:Public methods on Exception should not include backtrace?
39-
fails:Public methods on Exception should not include location
40-
fails:Public methods on Exception should not include set_context
4138
fails:Public methods on Exception should include respond_to?
4239
fails:Public methods on FalseClass should include ===
4340
fails:Public methods on TrueClass should include ===

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

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,6 @@ def to_s
6565
# #initialize again, BUT not a subclasses initialize.
6666
alias_method :__initialize__, :initialize
6767

68-
def backtrace?
69-
result = Primitive.exception_backtrace? self
70-
if !Primitive.undefined?(result)
71-
result
72-
else
73-
backtrace ? true : false
74-
end
75-
end
76-
7768
def set_backtrace(bt)
7869
case bt
7970
when Array
@@ -91,14 +82,6 @@ def set_backtrace(bt)
9182
end
9283
end
9384

94-
def set_context(ctx)
95-
if ctx.kind_of? Exception
96-
@parent = ctx
97-
else
98-
set_backtrace(ctx)
99-
end
100-
end
101-
10285
def inspect
10386
s = self.to_s
10487
if s.empty?
@@ -170,10 +153,6 @@ def exception(message=nil)
170153
self
171154
end
172155

173-
def location
174-
[context.file.to_s, context.line]
175-
end
176-
177156
def self.to_tty?
178157
# Whether $stderr refers to the original STDERR and STDERR is a tty.
179158
# When using polyglot stdio, we cannot know and assume false.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -688,8 +688,8 @@ def raise(exc = undefined, msg = undefined, ctx = nil)
688688
else
689689
exc = Truffle::ExceptionOperations.build_exception_for_raise(exc, msg)
690690

691-
exc.set_context ctx if ctx
692-
Primitive.exception_capture_backtrace(exc, 1) unless exc.backtrace?
691+
exc.set_backtrace(ctx) if ctx
692+
Primitive.exception_capture_backtrace(exc, 1) unless Truffle::ExceptionOperations.backtrace?(exc)
693693
Primitive.exception_set_cause exc, last unless Primitive.object_equal(exc, last)
694694
end
695695

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ def raise(exc = undefined, msg = undefined, ctx = nil)
183183

184184
exc = Truffle::ExceptionOperations.build_exception_for_raise(exc, msg)
185185

186-
exc.set_context ctx if ctx
187-
Primitive.exception_capture_backtrace(exc, 1) unless exc.backtrace?
186+
exc.set_backtrace(ctx) if ctx
187+
Primitive.exception_capture_backtrace(exc, 1) unless Truffle::ExceptionOperations.backtrace?(exc)
188188

189189
Truffle::ExceptionOperations.show_exception_for_debug(exc, 1) if $DEBUG
190190

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,15 @@ def self.backtrace_message(highlight, reverse, bt, exc)
123123
end
124124
end
125125

126+
def self.backtrace?(exc)
127+
result = Primitive.exception_backtrace? exc
128+
if Primitive.undefined?(result)
129+
exc.backtrace ? true : false
130+
else
131+
result
132+
end
133+
end
134+
126135
def self.append_causes(str, err, causes, reverse, highlight)
127136
if !Primitive.nil?(err.cause) && Exception === err.cause && !causes.has_key?(err.cause)
128137
causes[err.cause] = true

0 commit comments

Comments
 (0)