exceptions and patterns
hi,
i created a bunch of exceptions as an exacmple
class MyException extends Exception{
}
and an interface to handel different ways to handel my exceptions say
interface HandelInterface {
handel(Exception exp);
}
i created a class that implements the interface
class GErrorHandel implements HandelInterface{
handel (Exception exp){
if (exp instanceof MyException)
System.out.println("My exception");
}
}
i created a factory to choose the required handeler and the factory is singleton but the method getInstance() returns an instance of the interface HandelInterface instead of returnning an instance of the factory (lets call the factory HandelerFactory).
then i used the handler and that's when i my problems rise up and shine :)
in a class A when i figur that there is a problem and i want to deal with it i would say
HandlerFactory.getInstance().handel();
in the method handel() i use the JOptionPane.showMessageDialog()
now what happens is that i get the message that i am supposed to get BUT in the console i get a huge error message which contains the stakc trace (i think) which i thought that i shouldn't get since i am dealing with the exception using the JOptionPane.showMessageDialog.
that was the first problem.. the second problem happen this way ..
my application does some operations then it starts creating the GUI, now if anything goes wrong causing the handel() to work before the GUI gets created i don't get the JOptionPane.showMessageDialog() message AND the application would stop without continuing with creating the GUI or anything , just stops .. but it doesn't print the stack trace !
what could be the problem and is there anyway to deal with it ?
thanks for helping
Musab

