How to bypass ExceptWarn.py exceptions/errors

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jesuscider
    New Member
    • Aug 2010
    • 5

    How to bypass ExceptWarn.py exceptions/errors

    I used ExceptWarn.py to catch exceptions/errors in my sds/2 custom member, now the system makes the user hit OK every time the error message pop out... Is there any way I could put those messages in a warning message list allowing processing to finish without having to hit OK?
    Last edited by Niheel; May 6 '11, 04:34 AM. Reason: should always post quest as new if it's been a long time since the last post.
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    I am sure there is a way do do what you describe. Here is a common usage (snippet from BentBolt_v3.04. py):
    Code:
    from macrolib.ExceptWarn import formatExceptionInfo
    
    
            ## Set self.boltType
            dlg1 = setTypeDialog(self)
            try:
                dlg1.get().done()
            except ResponseNotOK:
                self.cleanUP()
                return
            except Exception, e:
                Warning(formatExceptionInfo())
                self.cleanUP()
                return
    Upon an error, the error information is displayed in a warning widget, cleanup is performed, and the script terminates. You could do something like this instead:
    Code:
    from macrolib.ExceptWarn import formatExceptionInfo
    
    errorList = []
    
    try:
        # some code to execute
    except Exception:
        errorList.append(formatExceptionInfo())
    
    print "\n".join(errorList)
    Most of the time you would not want the code to proceed when an error occurs. If an inconsequential error does occur, a simple pass may be more appropriate.
    Code:
    try:
        # some code to execute
    except:
        pass

    Comment

    • jesuscider
      New Member
      • Aug 2010
      • 5

      #3
      Thank you very much bvdet that was a great help..

      Comment

      Working...