taoensso / carmine

Redis client + message queue for Clojure
https://www.taoensso.com/carmine
Eclipse Public License 1.0
1.15k stars 131 forks source link

Carmine throws generic Exception #82

Closed Satshabad closed 10 years ago

Satshabad commented 10 years ago

If I try (wcar {} (car/ping)) when I am not running redis I get a message saying

ConnectException Connection refused java.net.PlainSocketImpl.socketConnect

Which makes me think I should do this

(try
  (wcar {} (car/ping))
  (catch ConnectException e (prn "here"))

But, that doesn't work. I look at the stack track and I see:

java.lang.Exception: Carmine connection error
at taoensso.carmine.connections$pooled_conn.invoke(connections.clj:161)
at songkick_playlist.handler$eval8811.invoke(form-init5585674532069117541.clj:2)

and

(try
  (wcar {} (car/ping))
  (catch Exception e (prn "here"))

works fine.

So in conclusion, you should either propagate the original ConnectException, or you should have your own that I can catch. There is a lot that can go wrong with (car/ping)

Also, if there is a better way to check if a server exists (say like (car/nil-if-down)) let me know.

ptaoussanis commented 10 years ago

Hi Satshabad,

So in conclusion, you should either propagate the original ConnectException, or you should have your own that I can catch.

Any connection error will throw with as a "Carmine connection error" Exception, with the original exception attached as a cause. That should be what you're looking for?

Also, if there is a better way to check if a server exists

No, I think what you're doing here is quite appropriate - I do something similar.

Hope that helps, cheers! :-)