-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid re-wrapping query validation exceptions into IllegalArgumentException
it they already are one
#2736
Comments
Digging into this, it's unfortunately not as easy as anticipated. The bootstrap of a repository includes a couple of layers of abstraction to be able to plug different implementation strategies. Schematically, they look something like this:
The assumed obsolete step is 3, as I originally assumed that one
On level three, we currently do not report the actual query being validated, which might create the impression that 3 is identical to 2, which it is not. So, I think we rather should enrich the exception message on level 3 with the actual query and keep that wrapping. |
When validating manually declared queries on repositories, the exception that captures the query to validate now actually also reports it in the exception message. Related ticket: #2736.
It turns out, we actually could avoid one layer of indirection, if The method signatures in |
I’m interested in this issue. |
History
In around 2012 we faced the problem of some persistence providers not producing the correct exceptions for calls to
EntityManager.createQuery(…)
(reported here). As a response, we added a rather broad catch clause toSimpleJpaQuery.validateQuery(…)
that wraps anyRuntimeException
in anIllegalArgumentException
.Problem
If the original exception already is an
IAE
, and that seems to be the case as of today, we will just end up re-wrapping it without further benefit. This was brought up here, just recently.Suggested solution
We could actually just throw the original exception to avoid the wrapping for this particular case.
The text was updated successfully, but these errors were encountered: