File tree Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Original file line number Diff line number Diff line change 36
36
ByteArrayInputStream ByteArrayOutputStream
37
37
PipedInputStream PipedOutputStream]
38
38
[com.jcraft.jsch
39
- JSch Session Channel ChannelShell ChannelExec ChannelSftp
39
+ JSch Session Channel ChannelShell ChannelExec ChannelSftp JSchException
40
40
Identity IdentityFile Logger KeyPair LocalIdentityRepository]))
41
41
42
42
; ;; forward jsch's logging to java logging
@@ -373,7 +373,28 @@ keys. All other option key pairs will be passed as SSH config options."
373
373
(defn open-channel
374
374
" Open a channel of the specified type in the session."
375
375
[^Session session session-type]
376
- (.openChannel session (name session-type)))
376
+ (try
377
+ (.openChannel session (name session-type))
378
+ (catch JSchException e
379
+ (let [msg (.getMessage e)]
380
+ (cond
381
+ (= msg " session is down" )
382
+ (throw (ex-info (format " clj-ssh open-channel failure: %s" msg)
383
+ {:type :clj-ssh/open-channel-failure
384
+ :reason :clj-ssh/session-down }
385
+ e))
386
+ (= msg " channel is not opened." )
387
+ (throw (ex-info
388
+ (format
389
+ " clj-ssh open-channel failure: %s (possible session timeout)"
390
+ msg)
391
+ {:type :clj-ssh/open-channel-failure
392
+ :reason :clj-ssh/channel-open-failed }
393
+ e))
394
+ :else (throw (ex-info (format " clj-ssh open-channel failure: %s" msg)
395
+ {:type :clj-ssh/open-channel-failure
396
+ :reason :clj-ssh/unknown }
397
+ e)))))))
377
398
378
399
(defn sftp-channel
379
400
" Open a SFTP channel in the session."
You can’t perform that action at this time.
0 commit comments