I am using Spring AOP for exception handling.
I am using around advice as I want to log the input parameters.
My aspect method is like this:
public Object methodName(ProceedingJointPoint pjp){
Object returnVal = null;
try{
returnVal = pjp.proceed();
} catch(Throable t) {
// Log exception
}
return returnVal ;
}
The problem currently I am facing is : When the exception is occured I want to log the exception but I do not want to return null (returnval). Is it possible?
In the normal scenario without AOP : when some line in the method throws an Exception after that line , no other lines get executed. I want behaviour like that.
How can we ahieve it?
Good old checked exceptions, the Java design mistake that just keeps on biting.
Just rethrow the throwable:
See here: https://stackoverflow.com/a/5309945/116509