It will hide the original exception.
As one method call can only throw one exception, the exception from the finally
block will completely replace and hide an exception from the main part of your method.
Do you want to throw the finally exception at all?
Not doing so makes things much easier and often is a correct decision.
Typically, finally
blocks are meant to close some resource. So, if the method body was able to read the result asked for, I'd regard that a success, even if the method wasn't able to close some resource, so I'd log that as a warning and continue (and then the report will be happy as well).
But maybe you decide the other way: if something goes wrong in the finally
block, you see that as such a failure of the methodName()
call that you have to signal that as a failure to your caller. Then you can end up with two competing exceptions and you have to decide which one to throw to your caller. And you should log the other one, so it isn't completely lost.
The main-body one typically is the more interesting one, but isn't easily accessible: you have to introduce an Exception variable outside the try-catch-finally block, initialized to null, where you store any main-body exception, so you can throw that one from the finally block. The resulting code will be weird...
So I'd stay with your approach (if you decide an exception in the finally block to be a failure of the complete method), just make sure the original exception is logged. This will lead to double log entries, which should be avoided, but better logged twice than never.