Posted By

magicrebirth on 12/22/09


Tagged

exception


Versions (?)

Catching and throwing exceptions


 / Published in: Python
 

  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  

You need to login to post a comment.