[Solved] where should i catch the exception???? main public method? or private method? [closed]


Though question seems to be very broad, but you need understanding on Java Exception framework + bit of design patterns

1.) If you are exposing some public methods in a service, it is always better to catch exception

Log Exception -> Return proper error code/message

2.) throwing exception means everyone who is calling that method has to handle the exception on its own.

3.) If there are any changes to the internal implementation of the method, then you might end up throwing a different exception.

4.) Also throwing the superclass Exception, again looses the focus from the precision.

solved where should i catch the exception???? main public method? or private method? [closed]