Look in Exception class and its derived classes, I think they have some kind of method that will give you the trace of what functions are or were being used