Hi,
i have a small query.Kindly find the below code.
public static void handleException(throwable ex)
{
if(ex instanceof NamingException)
{
showError("NamingException");//showError is a method
}
if(ex instanceof SQLException)
{
showError("SQLException");//showError is a method
}
if(ex instanceof IOException)
{
showError("IOException");//showError is a method
}
//goes on
}
My doubt is how can i avoid these many If conditions?Is there any
pattern for this or is there any better way to implement this?Kindly let me know.