Skip to content

Commit f6a5161

Browse files
committed
Add handle_error to command_stream
1 parent ec8778b commit f6a5161

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/net/ssh/command_stream.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def initialize(ssh, cmd = nil, pty: false, cleanup: false)
9696
rssh.close
9797
end
9898
end
99-
rescue ::Exception => e
99+
rescue ::StandardError => e
100100
# XXX: This won't be set UNTIL there's a failure from a thread
101101
self.error = e
102102
ensure
@@ -113,6 +113,11 @@ def verify_channel
113113
end
114114
end
115115

116+
def handle_error(error: nil)
117+
self.error = error if error
118+
cleanup
119+
end
120+
116121
def cleanup
117122
self.monitor.kill
118123
self.lsock.close rescue nil

0 commit comments

Comments
 (0)