By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,400 Members | 903 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,400 IT Pros & Developers. It's quick & easy.

How to bypass exceptions/errors

P: 5
I used 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?
May 6 '11 #1
Share this Question
Share on Google+
2 Replies

Expert Mod 2.5K+
P: 2,851
I am sure there is a way do do what you describe. Here is a common usage (snippet from
Expand|Select|Wrap|Line Numbers
  1. from macrolib.ExceptWarn import formatExceptionInfo
  4.         ## Set self.boltType
  5.         dlg1 = setTypeDialog(self)
  6.         try:
  7.             dlg1.get().done()
  8.         except ResponseNotOK:
  9.             self.cleanUP()
  10.             return
  11.         except Exception, e:
  12.             Warning(formatExceptionInfo())
  13.             self.cleanUP()
  14.             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:
Expand|Select|Wrap|Line Numbers
  1. from macrolib.ExceptWarn import formatExceptionInfo
  3. errorList = []
  5. try:
  6.     # some code to execute
  7. except Exception:
  8.     errorList.append(formatExceptionInfo())
  10. 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.
Expand|Select|Wrap|Line Numbers
  1. try:
  2.     # some code to execute
  3. except:
  4.     pass
May 6 '11 #2

P: 5
Thank you very much bvdet that was a great help..
May 9 '11 #3

Post your reply

Sign in to post your reply or Sign up for a free account.