Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jgit-dev] JGit and exceptions

We have a lot of places where I think our error handling is broken. I probably contributed myself, but nevertheless..

I see the interpretation (my interpretation of the code) that JGitInternalException is part of the API. It's not, really. It's a catch-all for "I didn't think of that and now things broke, so we have to abort" so we can diagnose when the unthinkable happens. As a result someone may report an issue that we discover that we indeed can and should handle using a GitAPIException. Maybe we should just have used RuntimeException directly instead of JGitInternalExceotion, but I'm not sure that would have helped.

You're not supposed to catch and take specific actions depending the cause or error message contained in a JGitInternalException. If you cannot code without that, you're
either doing something wrong or you have discovered an API design error/omission.

So, it you write a JUnit test and want to catch a JGitInternalException, think again. It's probably not right. If you see it in code review, the -1 vote is handy. 

As always there are exceptions, but I think this is the general rule here.

-- robin

Back to the top