""" Demonstration of exception handling """


class SpecialException(Exception):
    pass

class ReallySpecialException(SpecialException):
    pass


def exception_raiser(value):
    """ A function to raise exceptions """

    if value < 0:
        raise ReallySpecialException('negative number')
    if value == 0:
        return 10 / value
    if value < 10:
        raise SpecialException('value is less than 10')


def exception_handler(value):
    try:
        # the code you think might cause an error
        exception_raiser(value)
        # we won't get to the line below if an exception occurs
        value = 7
    except ReallySpecialException:
        print('that number is negative')
    except SpecialException:
        # what to do if an error occurs
        print('sorry, bad value')
    except ZeroDivisionError:
        # often this will contain code that
        # does more than print
        value = 1
    except Exception:
        print('something else went wrong, uh oh')
    else:
        # code here is executed only if no exception occurs
        print('yay')
    finally:
        # this is executed no matter what
        # whether or not an exception occured
        print('no except')



if __name__ == '__main__':
    exception_handler(-1)
