Guest User

Untitled

a guest
Jan 18th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. class MyException(Exception):
  2. def __str__(self):
  3. return self.args[0]
  4.  
  5.  
  6. def DoWork():
  7. raise MyException("My hoverboard is full of eels")
  8. pass
  9.  
  10. if __name__ == '__main__':
  11. try:
  12. DoWork()
  13. except MyException as ex:
  14. print("This will get printed: " + str(ex)) #Line1
  15. print("This will not get printed and will raise exception: " + ex) #Line2
  16.  
  17. print("This will also work: %s" % ex)
Add Comment
Please, Sign In to add comment