Tech Novice
asked on
Can we break sequence of the throw in java.
Hi,
I need to create a common method which handles all the exception.There are controllers,logic layers,dao layers.
Flow is
isValidLogin() calls the method of logic layer validUserLogic() further goes to dao layer (validUserDAO) ,Now exception occurrred in the dao layer and the exception is thrown using (throw new AppBussinessException)
What i need is when exception is thrown from dao layer it should go to common classs which will take care of the exception.
How to achieve this?
I need to create a common method which handles all the exception.There are controllers,logic layers,dao layers.
Flow is
isValidLogin() calls the method of logic layer validUserLogic() further goes to dao layer (validUserDAO) ,Now exception occurrred in the dao layer and the exception is thrown using (throw new AppBussinessException)
What i need is when exception is thrown from dao layer it should go to common classs which will take care of the exception.
How to achieve this?
ASKER
Thanks for reply
You can attach an "uncaught exception handler" to the thread and have that handle the exception.
Can u please elaborate so that i can apply,somehow this looks feasible
You can attach an "uncaught exception handler" to the thread and have that handle the exception.
Can u please elaborate so that i can apply,somehow this looks feasible
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I am having web application in which i don't create threads,which are in built created by tomcat on each request, then how to handle in such scenario.
ASKER
any clue?
Either you need a "top level handler" that catches all of these exceptions and explicitly passes them to the class that you wish to handle them
or
You can attach an "uncaught exception handler" to the thread and have that handle the exception.
Both require that you can set the correct exception handling (which exceptions are caught, which not) higher up the call stack. Which may or may not be possible given your code base and how the DAO layer is called.
Doug