How to return the function or sub where the error occured?
I know you can use erl, to return the line number of the error if you have it set, I would like to return the function or sub where the error occured to my error handeling procedure, any thoughts?
Unfortunately there is no direct built-in way to access the call stack to find out which sub or function was active when an error occurred. Some posters have implemented their own stack structures, pushing the name of the current sub or function on entry to the routine and popping the name off at the end of the routine. If you choose to go the same route at least you can then get the top of stack value within your error-handling routine to recover the last routine which was in use.
Alternatively you can handle errors in all routines. It makes using a standard error routine procedure more complex, but it could be done if only basic things are required from the said routine.
Comment