Python/Exceptions
From charlesreid1
Class exceptions:
Abstract datatype example
The case of exception handling for an abstract data type like a stack is pretty clear-cut: there are two explicit error cases that it should handle, both when items are requested and the stack is empty. To raise these exceptions, we just do a variation of raise Exception("oops"):
class Empty(Exception):
pass
Done. Now we can do raise Empty("oops, empty stack").