mpenet / alia

High performance Cassandra client for clojure

Home Page:https://mpenet.github.io/alia/qbits.alia.html#docs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow for java driver exceptions to surface to to the caller of qbits.alia/execute

mourjo opened this issue · comments

We recently ran into an issue where we were retrying timeout writes based on the type of exception that was thrown by qbits.alia/execute. Because every exception is wrapped with qbits.alia/ex->ex-info, we are losing the class of exception that the caller sees.

In fact, since we care about the exception object's class for both logging and retrying, we had to add a middleware to unwrap the ex-info object and let the Java exception surface to the caller. I was wondering if you would consider exposing this as part of your API.

If you think it's something you will consider, I can submit a pull request!

I guess it could be made into a protocol function, that way you could just extend the protocol, return the exception and get the original class if you'd like. Let me think about it.

Alternatively you could just do this in your app to get the original exception thrown.

(alter-var-root #'qbits.alia/ex->ex-info (constantly (fn [e _ _] e)))

I think that's probably your best bet for now.

I am actually using catching ExceptionInfo and throwing the :exception in its data. That keeps the code easier to maintain.