Skip to content

Commit 267b528

Browse files
committed
Merge branch 'release/0.5.5'
2 parents 0dfb705 + 6f930be commit 267b528

File tree

4 files changed

+33
-6
lines changed

4 files changed

+33
-6
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ system, then a local, isolated ssh-agent can be used.
8686

8787
```clj
8888
(let [agent (ssh-agent {:use-system-ssh-agent false})]
89-
(add-identity agent "/user/name/.ssh/id_rsa")
89+
(add-identity agent {:private-key-path "/user/name/.ssh/id_rsa"})
9090
(let [session (session agent "localhost" {:strict-host-key-checking :no})]
9191
(with-connection session
9292
(let [result (ssh session {:in "echo hello"})]
@@ -143,7 +143,7 @@ Thanks to [Ryan Stradling](http://github.com/rstradling) for these.
143143
Via [clojars](http://clojars.org) and
144144
[Leiningen](http://github.com/technomancy/leiningen).
145145

146-
:dependencies [clj-ssh "0.5.4"]
146+
:dependencies [clj-ssh "0.5.5"]
147147

148148
or your favourite maven repository aware tool.
149149

ReleaseNotes.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Release Notes
22

3-
Current release is 0.5.4
3+
Current release is 0.5.5
4+
5+
## 0.5.5
6+
7+
- Wrap open-channel exceptions
8+
When .openChannel throws an exception, wrap it in an ex-info exception.
9+
This allows easier procession of the exceptions in consuming code.
410

511
## 0.5.4
612

project.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(defproject clj-ssh "0.5.4"
1+
(defproject clj-ssh "0.5.5"
22
:description "Library for using SSH from clojure."
33
:url "https://github.com/hugoduncan/clj-ssh"
44
:license {:name "Eclipse Public License"

src/clj_ssh/ssh.clj

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
ByteArrayInputStream ByteArrayOutputStream
3737
PipedInputStream PipedOutputStream]
3838
[com.jcraft.jsch
39-
JSch Session Channel ChannelShell ChannelExec ChannelSftp
39+
JSch Session Channel ChannelShell ChannelExec ChannelSftp JSchException
4040
Identity IdentityFile Logger KeyPair LocalIdentityRepository]))
4141

4242
;;; forward jsch's logging to java logging
@@ -373,7 +373,28 @@ keys. All other option key pairs will be passed as SSH config options."
373373
(defn open-channel
374374
"Open a channel of the specified type in the session."
375375
[^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)))))))
377398

378399
(defn sftp-channel
379400
"Open a SFTP channel in the session."

0 commit comments

Comments
 (0)