Refine interface to throw detailed exception
Brought to you by:
wimpi
I wanted to use TCPMasterConnection.connect().
The API states, that connect() throws an Exception. I know, that a connect might fail because of e.g. Network problems and I would like to handle those failures.
But I can not handle them properly, because the following code will catch all Exceptions, that do exist, including RuntimeExceptions like NullpointerException... etc:
try {
tcp.connect()
} catch (Exception e) {
// what kind of exception is this?
}
I suggest to change the API for connect to declaire explicitly the thrown exceptions, that the caller should except (e.g. IOException).