Forum Discussion

exdunepilot's avatar
exdunepilot
Contributor
6 years ago

Python Error Handling Not Executing Finally Block - TestComplete 14.0

Try/Except works, but an exception is thrown in the except block (seems to refer to this syntax: str(err)) and never makes it to the finally block.  TestComplete 12.6 did not have this issue.

 

 

  • Something else to check:

    In the TestItems page, right click and select "Field Chooser".  There should be a field of "on exception".  Add that to your test item list.  I BELIEVE this defaults to "Stop test item" on exception. So, you're throwing an "exception" in your code.  This would then prompt the automation to halt on that exception which is why it doesn't get to the "finally" clause.  You can set that to "continue running" as well. See if that corrects your problem.

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Please share your code.  It will be easier to debug if we can see what we're debugging.

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    OK... just thinking outloud (after doing some research), in Python (and I'm no Python expert) as I understand it the str method converts whatever is in the parentheses into a string.

    I don't know for sure (because you haven't shown me your actual code), but I suspect "err" is an object of some sort.  In JavaScript, when you do something like

     

    try {
    
    }
    catch (e) {
    
    }
    finally {
    
    }

    In the above code the e is an object with various properties.  So, it doesn't convert, easily, to a string.  If Python does something similar, that could very well be the problem.  

     

    Again, seeing your code would be better.

    • exdunepilot's avatar
      exdunepilot
      Contributor

      Yes, I believe you are correct.  However, the e had no problems converting in 12.6 (or older versions for that matter).  Something seems to have changed in debugging.  I'm noticing more cryptic debug messages and missing call stack items overall.   May need to rollback to 12.6.   I'll post more when I can be more exact!