Mars83

MyOwnError

Sep 15th, 2012
45
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. '''
  2. Created on 12.09.2012
  3.  
  4. @author: Mars83
  5. '''
  6.  
  7. class MyOwnError(Exception):
  8.     """ This class represents a custom error. """
  9.     def __init__(self, value):
  10.         """ Ctor of MyOwnError. """
  11.         self.value = value
  12.     def __str__(self):
  13.         """ toString method of MyOwnError. """
  14.         return repr(self.value)
  15.  
  16. try:
  17.     raise MyOwnError("my own error raised")
  18. except MyOwnError as moe:
  19.     print(moe)
  20.  
  21. try:
  22.     2/0
  23. except ZeroDivisionError as zde:
  24.     print(zde)
  25.  
  26. try:
  27.     open("")
  28. except IOError as ioe:
  29.     print(ioe)
RAW Paste Data