Project Exception : How you handled exceptions in your project?
As part of my project we are handling the exception, generally in my project we have handle user defined exception, based on the business requirement we have categorized user defined exception into different types of exception like-
A) Business Exception
B) System Exception
C) Service Exception
Here, when the user sends the request element (like- fistName, LastName, D.O.B, MobNo and etc.) data, if that data is not valid then we are throwing the some user defined exception. This data not sending to the process layer, here only we are handling an exception.
A) Business Exception :- Business exception means if the User sending the request element, that request element is not valid then that time we handle the business exception.
To handle this, we are writing the some user defined exception class and some Enum class/properties files/XML files.
By this class we handle the business exception. In business exception coming the some DataException this one also related to the request data only.
B) System Exception : – This Exception coming at the time of running the service, this one also related to the hardware system, this exception willbe handling by the Admin team. This exception we handle in Throw able class exception.
C) Service Exception : – In service exception we handle the service related exception like- DBConnection error.
In my project having layers like- service layer, process layer, Integration layer.
In Integration layer, as per business requirement we are categorized different kind of user defined exceptions.
Here, I am explaining the some exceptions:
NumberFormateException,
ClassCastException,
ClassNotFoundException,
FileNotFoundException,
NullPointerException and etc.
NullPointerException :-
To resolve the NullPointerException before creating the object we can write some if_else (for avoiding this exception) statement and checkout this, and make sure that object not null, if object whatever you pass is null then that time you will get NullPointerException.
ClassNotFoundException :-
At the time of loading the class if that class is not available then that you’ll get this Exception.To resolve this Exception you make sure whatever you load the class, that class is available. Another style of handle this exception is you should pass the class otherwise you will get this exception.