oliyh / carmine-streams

Utility functions for working with Redis streams in carmine
36 stars 2 forks source link

SocketException is not properly handled #18

Closed zerg000000 closed 11 months ago

zerg000000 commented 11 months ago

When SocketException is thrown, we will receive the following exception

java.lang.UnsupportedOperationException: nth not supported on this type: SocketException

Since we are trying to destruct Exception as a vector at this line

https://github.com/oliyh/carmine-streams/blob/572de00fbf026eb262b2e6adf5a0f5661d1c1ca9/src/carmine_streams/core.clj#L446

we could fix this by changing the return value in (catch ...). e.g.

(try
  ...
 (catch Exception ex
    [false ex])
oliyh commented 11 months ago

Hi,

Thanks for writing this up.

I wonder if this behaviour could or should also be changed in carmine, to make its API more consistent? But yes, I think carmine-streams should guard against this.

zerg000000 commented 11 months ago

It should match the destructuring.

(let [[_setname-ok? response]
      (try
        ... ;; should return [ v1 v2 ]
       (catch Exception e
         ... ;; should also return [ v1 v2 ], currently return e
        ))]
  ...
)
oliyh commented 11 months ago

Hi,

Please try version 0.2.2 on clojars

Thanks