Created
December 2, 2022 18:25
-
-
Save JacekDubikowski/167bcaaab151f9d4ad6f033ef1543cec to your computer and use it in GitHub Desktop.
Catch block
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class TransactionalInterceptedWriter { | |
| private CodeBlock catchClause() { | |
| return CodeBlock.builder() | |
| .beginControlFlow("catch ($T e)", Exception.class) | |
| .beginControlFlow("try") | |
| .addStatement(TRANSACTION_MANAGER + ".rollback()") | |
| .endControlFlow() | |
| .beginControlFlow("catch ($T innerException)", Exception.class) | |
| .addStatement("throw new $T(innerException)", RuntimeException.class) | |
| .endControlFlow() | |
| .addStatement("throw new $T(e)", RuntimeException.class) | |
| .endControlFlow() | |
| .build(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment