I was working on an assigment in Java, and I wondered if it's possible to know which object throwed an exception.
I know that if you make your custom exceptions, you can modify the constructor and have a reference to the object:
public class MyEx extends Throwable {
private MyObject object;
public MyEx(MyObject o){
super();
}
public MyObject getSource(){
return object;
}
}
but I don't know if there exists another way of catching who throwed the exception. Do you know any other way?