Is it possible to pass an object to the constructor when throwing exceptions?
Assume that the package contains the following code.
throw new MyException(object);
MyException Class:
Object object;
public MyException(Object object) {
super();
this.object = object;
}
public Object getObject() {
return object;
}
And later, say, in the GUI, we must handle the exception that was sent to the service. We just get an exception and want to access the object passed in the constructor. It works. But is this true in terms of style?
Is using getObject () method correct?
source
share