seancorfield / next-jdbc

A modern low-level Clojure wrapper for JDBC-based access to databases.
https://cljdoc.org/d/com.github.seancorfield/next.jdbc/
Eclipse Public License 1.0
755 stars 90 forks source link

Document caveats around PostgreSQL exception handling #226

Closed sheluchin closed 1 year ago

sheluchin commented 1 year ago

Hi, @seancorfield. You gave me some advice about exception handling in next.jdbc the other day on Slack and we discovered that PostgreSQL has a non-standard way of dealing with exceptions. Specifically, it doesn't use the standard SQL exception hierarchy, but just throws PSQLException. This is likely to be the case until https://github.com/pgjdbc/pgjdbc/pull/1904 gets merged.

You asked me to open an issue here to remind you to mention this in the Tips and Tricks section of the docs to help any next.jdbc users which might be using or considering Postgres.

Thanks for your help!

seancorfield commented 1 year ago

I dug into this a bit and the whole area is pretty vendor-specific, so I've written up a new section in Tips & Tricks that covers exception handling in general rather than try to offer database-specific advice.

sheluchin commented 1 year ago

@seancorfield Thank you for looking into this and providing some guidance. Sounds like a complicated situation indeed, but the content you added is helpful as a basis.

seancorfield commented 1 year ago

Yeah, when I started reading various JDBC driver docs and experimenting in the REPL with the various ones I test against, I realized that it was way worse than our discussion on Slack suggested! 😱