Skip to content

Commit 813a424

Browse files
committed
Include original backtrace in new TimeoutError
Fixes #430.
1 parent abf65e1 commit 813a424

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/redis/client.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,11 @@ def reconnect
218218

219219
def io
220220
yield
221-
rescue TimeoutError
222-
raise TimeoutError, "Connection timed out"
221+
rescue TimeoutError => e1
222+
# Add a message to the exception without destroying the original stack
223+
e2 = TimeoutError.new("Connection timed out")
224+
e2.set_backtrace(e1.backtrace)
225+
raise e2
223226
rescue Errno::ECONNRESET, Errno::EPIPE, Errno::ECONNABORTED, Errno::EBADF, Errno::EINVAL => e
224227
raise ConnectionError, "Connection lost (%s)" % [e.class.name.split("::").last]
225228
end

0 commit comments

Comments
 (0)