Message-ID: From: "vlsi (@vlsi)" To: "pgjdbc/pgjdbc" Date: Wed, 20 Aug 2025 18:48:10 +0000 Subject: Re: [pgjdbc/pgjdbc] issue #3779: SQLException subclasses support In-Reply-To: References: List-Id: X-GitHub-Author-Login: vlsi X-GitHub-Comment-Id: 3207633216 X-GitHub-Comment-Type: issue_comment X-GitHub-Issue: 3779 X-GitHub-Repo: pgjdbc/pgjdbc X-GitHub-Type: comment X-GitHub-Url: https://github.com/pgjdbc/pgjdbc/issues/3779#issuecomment-3207633216 Content-Type: text/plain; charset=utf-8 The culprit is that `PSQLException extends SQLException`, and we have tons of code that already catch `PSQLException` or cast `Throwable` to `PSQLException`. `PSQLException` predates `SQLRecoverableException`, so I would rather say JDBC spec is not backward-compatible when it comes to `SQLException` subtypes. Note that a single application might have **multiple** libraries that are either prepared or unprepared to `SQLRecoverableException`. I've asked ChatGPT, and it did not provide trivial approach to migrating pgjdbc to exception subtypes: https://chatgpt.com/share/68a6162a-8ca4-800f-a0db-a8e5ab0651df I don't think a connection-wide property like `throw_exceptions_as=psqlexception | psqlexception_subtypes` is not viable as, well, there might be multiple libraries which are either prepared or unprepared to throwable subtypes. ---- I think it might be a nice idea to have a mapper utility which would take `PSQLException` as an input and produce typed exception in return. It won't be completely portable though. Do you have any other suggestion?