Sonarqube defines a rule saying Generic exceptions should never be thrown (i.e. throw a dedicated exception instead of using a generic one.) However AOP ProceedingJoinPoint always throws generic Throwable and normally I am not interested in the exception at all and just throw it from the method like this:
@Around(...)
public void someMethod(ProceedingJoinPoint point) throws Throwable {
// do something...
point.proceed();
// do something else...
}
Obviously this is against the above-mentioned Sonarqube rule. Do I really have to wrapper it with try catch and log the throwable or something? What is the best practice on this?
You can safely mark this violation as a false positive and enter a descriptive comment. This kind of false positive should be rare enough to allow you to treat them individualy, and act accordingly - AoP API is a good example, legacy and/or badly written libraries is another. But do NOT add the files to exclusions, as you would loose other rules from the Sonar analysis