I am working as a contractor designing enterprise Java application for my client in the role of a technical lead. The application will be used by end users and there will be a support team who will support the application when we leave.
The other technical leads with whom I am working are under the impression that exception handling will make the code dirty. The system should throw checked exceptions only from the Service triertier and the rest of the code should throw Runtimeruntime exceptions from all other tiers so that there is no need to handle the unchecked exceptions.
I want to hear others experiences on this. What is a need to ever throw a unchecked exception in a business application?
From my experience in the past about runtime exceptions:
Unchecked exceptions make the code unpredictable because they do not show up even in the Javadoc.
Throwing Unchecked exceptions in a business application is non-sense because when you throw it and it goes straight on Users face, how do you explain it to the user? I have seen enough of web application which show "500 -Internal Error. Contact Administrator"
500 -Internal Error. Contact Administratorwhich means nothing for a end user or to the support team managing the application.Throwing runtime exceptions forces the users of the class throwing the exception to walk through the source code to debug and see why the exception is thrown. This can only be avoided if the Javadoc of the runtime exception happens to be excellently documented which I find is never a case.