-
Hello, I am trying to use AOP to simplify exception handling for file storage operations and eliminate repetitive try-catch logic. The goal is to use an interceptor to catch a custom I have defined an interceptor which catches When I inject One fix is to declare that the method Thanks in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I don't think this is possible by the way how java works. With AOP or generally interceptors you cannot modify the signature of a method. The given Spring example targets a RestController. You never call those methods directly in the code (the framework does over reflection) that is why the compiler does not complain. You might want to checkout lomboks |
Beta Was this translation helpful? Give feedback.
I don't think this is possible by the way how java works. With AOP or generally interceptors you cannot modify the signature of a method. The given Spring example targets a RestController. You never call those methods directly in the code (the framework does over reflection) that is why the compiler does not complain.
You might want to checkout lomboks
@SneakyThrows
:https://www.baeldung.com/java-sneaky-throwsBut this pretty much rewrites your code with a preprocessor -> https://github.com/projectlombok/lombok/blob/master/src/core/lombok/SneakyThrows.java#L39