Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] JGit's overuse of IOException

Hi,

Masaya Suzuki wrote:

By defining a root exception as Matthias mentioned it would become API safe when introducing a new exception.

I maintain that (outside of org.eclipse.jgit.api.*, which is imitating commandline tools) this is a bad idea.

Java is designed with the list of exceptions a caller needs to handle as part of an API. Fighting that has only brought us pain. It's better on a method by method basis to list the exceptions we want the caller to handle, at an appropriate level of abstraction. As the library evolves, we will sometimes discover we want to throw another exception, and at that point we should introduce a new method and deprecate the old one since it affects callers.

More details about this are in Effective Java second edition p251 "Item 61: Throw exceptions appropriate to the abstraction".

Thanks,
Jonathan

Back to the top