Skip to content

Commit 273ece9

Browse files
committed
[refactor] only set backtrace when object differs
1 parent 67723a5 commit 273ece9

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/arjdbc/abstract/core.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,19 @@ def translate_exception_class(e, sql, binds)
4242
exception = translate_exception(
4343
e, message: message, sql: sql, binds: binds
4444
)
45-
exception.set_backtrace e.backtrace
45+
exception.set_backtrace e.backtrace unless exception.equal?(e)
4646
exception
4747
end
4848

49+
Throwable = java.lang.Throwable
50+
private_constant :Throwable
51+
4952
def translate_exception(exception, message:, sql:, binds:)
5053
# override in derived class
5154

5255
# we shall not translate native "Java" exceptions as they might
5356
# swallow an ArJdbc / driver bug into an AR::StatementInvalid !
54-
return exception if exception.is_a?(Java::JavaLang::Throwable)
57+
return exception if exception.is_a?(Throwable)
5558

5659
case exception
5760
when SystemExit, SignalException, NoMemoryError then exception

0 commit comments

Comments
 (0)