Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exceptions are caught but not rethrown by the reporter #1028

Open
TimvdLippe opened this issue Apr 11, 2017 · 3 comments
Open

Exceptions are caught but not rethrown by the reporter #1028

TimvdLippe opened this issue Apr 11, 2017 · 3 comments

Comments

@TimvdLippe
Copy link
Contributor

I ran SonarQube on the project and it reported numerous issues with the following description: Either log or rethrow this exception.

An concrete example is https://github.com/mockito/mockito/blob/release/2.x/src/main/java/org/mockito/internal/MockitoCore.java#L126 which shows that the Exception is caught, but not passed into the Reporter.notAMockPassedToVerifyNoMoreInteractions.

Should we update such usages to pass on the Exception and append it to the log of the reporter? That could potentially help Mockito users finding the root-cause.

@ChristianSchwarz
Copy link
Contributor

ChristianSchwarz commented Apr 11, 2017

Mockito should better avoid exception where possible rather than abusing them for control flow. In case of your example in MockitoCore.verifyNoMoreInteractions the exception can be avoided by calling MockUtil.isMock(..) before, this makes the intent clear.

@ChristianSchwarz
Copy link
Contributor

@TimvdLippe can you provide a list of "Either log or rethrow this exception" issues. It would be interesting to see what can be improved there.

@TimvdLippe
Copy link
Contributor Author

Small note by me: I tried to extract the list, but haven't been succesful just yet. If anyone knows how to extract a list from SonarQube, that would be greatly appreciated. I haven't found an option to do so just yet 😭

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants