Quickies

[categories] [index] [all (527)] [latest]

Python
  1. class MyException(Exception):
        def __init__(self, value):
            self.value = value
    
        def __str__(self):
            return repr(self.value)
    
    def myFunction():
        raise MyException("myValue")
    
    def handleException():
        try:
            myFunction()
        except MyException as e:
            print("-- exception: %s" % e)
    
    handleException();