Catching and throwing exceptions


/ Published in: Python
Save to your folder(s)



Copy this code and paste it in your HTML
  1. --- catch:
  2.  
  3. try:
  4. generateSomeException()
  5. except Exception, e: # Mother of all exceptions
  6. print e
  7.  
  8. --- throw:
  9.  
  10. try:
  11. raise Exception, "Something is rotten in the state of Denmark"
  12. except e:
  13. print e

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.