Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MyException(Exception):
- def __str__(self):
- return self.args[0]
- def DoWork():
- raise MyException("My hoverboard is full of eels")
- pass
- if __name__ == '__main__':
- try:
- DoWork()
- except MyException as ex:
- print("This will get printed: " + str(ex)) #Line1
- print("This will not get printed and will raise exception: " + ex) #Line2
- print("This will also work: %s" % ex)
Add Comment
Please, Sign In to add comment