How to return the function or sub where the error occured?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Andrew Hulting
    New Member
    • Dec 2010
    • 13

    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?

    Andrew
  • Stewart Ross
    Recognized Expert Moderator Specialist
    • Feb 2008
    • 2545

    #2
    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.

    -Stewart

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32656

      #3
      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

      Working...