Fork me on GitHub
#sql
<
2017-07-03
>
hackeryarn01:07:17

I am trying to test a java.sql.SQLException handler which unwraps the exceptions like below. However I'm not sure how I would throw this exception in a test.

(-> e
           (.getNextException)
           (.getMessage)
           (.startsWith "ERROR: duplicate key value"))
current mock (`.getNextException` returns nil on this):
(throw (SQLException. "ERROR: duplicate key value"))

hackeryarn01:07:45

Ah thank you @seancorfield, looks like a BatchUpdateException is actually thrown before the duplicate key exception and that's why the .getNextException is needed.

hackeryarn01:07:02

That helped me understand how the transaction is run a bit better too.