-
Notifications
You must be signed in to change notification settings - Fork 350
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
GH-611 added JdbcExceptionTranslator #1956
base: main
Are you sure you want to change the base?
Conversation
spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/AggregateChangeExecutor.java
Outdated
Show resolved
Hide resolved
@@ -110,12 +114,12 @@ private void execute(DbAction<?> action, JdbcAggregateChangeExecutionContext exe | |||
} else { | |||
throw new RuntimeException("unexpected action"); | |||
} | |||
} catch (Exception e) { | |||
} catch (RuntimeException e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to me that we should revisit our exception handling. DbActionExecutionException
doesn't seem particularly useful to the final application whereas it might be useful for our own internals.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mp911de Yeah... But this is not a part of this issue. Maybe we can create another issue to revise the default exception to be thrown? Or what should we do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that we're throwing DbActionExecutionException
and not a DAO exception, so I think that is indeed part of the issue. Looking at the code, we do not catch DbActionExecutionException
. That exception was introduced as part of introducing better means for debugging (#382) while the net effect was that we changed the API experience. What we could do is add DbActionExecutionException
as suppressed exception to the original one.
Paging @schauder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what you mean by "adding as suppresed exception".
In my understanding Surpressed exceptions are ones that get lost when a finalizer throws an exception itself.
We could instantiate a new exception with the same type as the original with the additional information of the DAEE, or even the DAEE as cause. That would certainly look strange, but might actually be rather useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something along the lines of:
catch(RuntimeException e) {
e.addSuppressed(new DbActionExecutionException(action));
throw e;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know addSuppressed
. It is a little hackish, but seems fine to me. It's not worse then the other variants I had in mind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
I'm still not happy with this.
I see two possible ways forward: b) Implement a @mp911de What do you think? |
I would honestly drop Going forward, I would even suggest introducing |
Just to clarify what wasn't clear to me from Marks statement: For this PR we want to completely drop the The MyBatis integration should eventually also get its |
Targeting #831 issue
CC: @schauder @mp911de