+ Reply to Thread
Results 1 to 6 of 6

Error handling with Call Stack and Execution Trace

  1. #1
    Registered User
    Join Date
    08-22-2011
    Location
    Berlin
    MS-Off Ver
    Excel 2010
    Posts
    51

    Error handling with Call Stack and Execution Trace

    It was too enticing. Once I've managed my new error handling including a call stack (for displaying the path from the error raising procedure back up to the entry procdure) I had a begin-of-procedure (push) and an end-of-procedure (pop) call in each procedure. Why not extending the call stack with a begin-of-trace along with each push and an end-of-trace with each pop by incorporating my PrecisionTimeTaking module? Now the error handling provides both: An error message at the entry procedure level, for example:

    Name:  ErrorMessage.jpg
Views: 161
Size:  40.5 KB

    And with the command mErrHndlr.DsplyTrace (when the conditional compile argument is ExecTrace=1) in the Immediate Window a complete execution trace (example of the trace of a test procedure demonstrating the included error messages raised for test purpose.:

    Name:  ExecTrace.jpg
Views: 198
Size:  213.5 KB


    When the error handling is incorporated a module/procedure will look as follows:
    Please Login or Register  to view this content.
    I always find the comfort for debugging is worth the little extra effort. Those who agree will find the complete solution in the Workbook ErrHndlr.xlsm for download.
    Copy from it the Standard Module mErrHndlr and the Class Modules clsCallStack and clsCallStackItem into your project and start using it.

    Looking forward for comments, questions, etc.
    Attached Images Attached Images      
    Last edited by Warbe; 10-11-2019 at 07:00 AM. Reason: code reworked for minor improvements

  2. #2
    Registered User
    Join Date
    08-22-2011
    Location
    Berlin
    MS-Off Ver
    Excel 2010
    Posts
    51

    Re: Error handling with Call Stack and Execution Trace

    Some minor changes are now available in the Workbook when downloaded.
    • The execution trace output to the immediate window is slightly more compact
    • The trace is automatically displayed whenever the "entry procedure" is reached (the top most procedure which has the Begin of Procedure) and End of Procedure) statements.
      I.e. there is no need to enter any command to display the execution trace. The conditional compile argument ExecTrace = 1 is all what is required.
    • The displayed execution trace will also tell the error line when provided with the error message
    • The displayed execution trace handles unpaired BoP/EoP statement as good as possible (but may fail in trying)
    • Support of the error line (Erl). The error line, when provided, is now passed and displayed in the error message and the execution trace. Remember
      Please Login or Register  to view this content.
      which may be the "godsend" when it comes to the problem to identify the code line which causes the error.

    A potentially annoying and difficult to handle issue are unpaired Begin/End of Procedure statements. I've tried my very best to even then keep the result reasonable. See test trace below. However, when the unpaired statements are in the top most "entry" procedure the ErrHndlr may not be able to work properly.
    Name:  ErrHndlr_2.jpg
Views: 135
Size:  45.0 KB

    I have used this error handler now for some months and are quite happy with it. It fully featured, easy to use, and requires a minimum effort to implement it into a VBA project.
    Last edited by Warbe; 12-31-2019 at 11:09 AM.

  3. #3
    Forum Contributor
    Join Date
    03-08-2018
    Location
    Denmark
    MS-Off Ver
    2016 for Windows
    Posts
    413

    Re: Error handling with Call Stack and Execution Trace

    Very Nice Warbe

    I will give it a go :-)

  4. #4
    Registered User
    Join Date
    08-22-2011
    Location
    Berlin
    MS-Off Ver
    Excel 2010
    Posts
    51

    Re: Error handling with Call Stack and Execution Trace

    Quote Originally Posted by nordicdust View Post
    Very Nice Warbe

    I will give it a go :-)
    Thanks for this feedback. Without it, I'd have the feeling shouting into the wood and nobody cares. A pity compared to the effort I've spent and still spend.

  5. #5
    Forum Contributor
    Join Date
    03-08-2018
    Location
    Denmark
    MS-Off Ver
    2016 for Windows
    Posts
    413
    Quote Originally Posted by Warbe View Post
    Thanks for this feedback. Without it, I'd have the feeling shouting into the wood and nobody cares. A pity compared to the effort I've spent and still spend.
    I can see that you have put a lot of time in this.
    My current project is too large to implement it in to. But my next will certainly have this in with credit to you.
    Happy New year 🍾👍😎

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,419

    Re: Error handling with Call Stack and Execution Trace

    @Warbe, can you attach the workbook rather than using dropbox?
    Cheers
    Andy
    www.andypope.info

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Runtime error 28 Call Stack
    By anrichards22 in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 09-18-2017, 11:37 AM
  2. VBA: test for top of call stack
    By Freek1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-03-2013, 09:46 AM
  3. How do the experts pass an error up the call stack?
    By foxguy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-28-2013, 05:23 PM
  4. Macro for Call Stack
    By Karthick083 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-21-2010, 06:33 AM
  5. can a macro see the call stack.
    By foxguy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-13-2009, 08:05 PM
  6. error 28: out of stack space call function
    By ina in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-24-2006, 02:30 PM
  7. [SOLVED] Re: Call Stack disabled
    By Martin Wheeler in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-07-2005, 08:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1