-
Notifications
You must be signed in to change notification settings - Fork 178
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
Allow access to io.r2dbc.postgresql.ExceptionFactory
exceptions from client code
#644
Comments
All exceptions implement |
A related request - I wanted to be able to test that my retry logic correctly handles |
Generally speaking, |
Sorry, I wasn't clear. I don't want to use the internal class in my retry condition. I am using the exception from the SPI project for that. But in my test, I want to be able to confirm that certain SQL error codes do in fact get turned into the R2dbcTransientException and get retried. If I just mock the SPI exception, then it becomes a very shallow test. |
Not quite sure I follow: Do you want to verify Currently, the combination that a SPI exception can implement |
Feature Request
Is your feature request related to a problem? Please describe
When using this driver via Spring, when exceptions that this driver throws occur, Spring wraps them into wrapper exceptions such that different drivers can be used (e.g., JPA, Hibernate, R2DBC, etc.).
My example is the
org.springframework.dao.DataIntegrityViolationException
(the name implies when it occurs), which wraps around aThrowable cause
that the driver threw. When using this R2DBC driver, that cause isio.r2dbc.postgresql.ExceptionFactory.PostgresqlDataIntegrityViolationException
.My use case was to access which constraint was violated in an
UPDATE
query to rethrow the exception with a specific human-readable error message (instead ofviolates unique constraint \"%s\"
).Sadly, since all the exceptions produced by the
ExceptionFactory
are non-public, I cannot import them into my client code to perform a cast of theThrowable cause
of Spring's exception to then access theErrorDetails
of the driver's exception which would contain the constraint that was violated which I am after, such as:Unfortunately, this code does not compile.
Describe the solution you'd like
If the exceptions produced by
io.r2dbc.postgresql.ExceptionFactory
werepublic
, the above example code would work.For instance, Hibernate or JPA do support this "correctly" via e.g.,
HibernateExceptionTranslator
that will (to stay with my example) bubble up aorg.hibernate.exception.ConstraintViolationException
as theThrowable cause
of Spring's wrapper exception which ispublic
, thus making this code compile (in current Java versions):Describe alternatives you've considered
N/A
Teachability, Documentation, Adoption, Migration Strategy
N/A
The text was updated successfully, but these errors were encountered: