Hi All,
Currently we plan to have custom exceptions for business related exception cases(extending runtime exceptions)used inside a typical 3-tier architecture. So accordingly we have a data access layer, service layer and a facade layer.
Basically exceptions will be caught, wrapped and propagated to the layers downstream. So the data Access layer in case of any business exception scenario will raise DataAccessException. The Service layer which calls the DAO layer will catch the DataAccessException , transform it to a ServiceException and rethrow it to the Facade layer.
Here the DataAccessException and ServiceException extend
java RuntimeException.
Now in the methods of the data access layer and service layer depending on business case scenario we raise the exception (throw new DataAccessException or say throw new ServiceException). The methods throwing the aforementioned exception declare the same as part of their method signature though for Runtime Exceptions we are not required to declare as part of the method signature.
My question is it a good idea to throw and declare a business exception though it is a java runtime exception and not a java checked exception.
I mean technically we can do it but I want to know your thoughts on this approach which typically is applied only in case of checked exceptions.
Or should we go and change our business related exception scenarios from unchecked runtime exceptions to checked exceptions.
Tx,
Manish