1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
class CommandlinesError(Exception):
"""Base exception class for all exceptions raised by the commandlines library"""
def __init__(self, message):
Exception.__init__(self, message)
class MissingArgumentError(CommandlinesError):
"""Missing argument exception"""
def __init__(self, argument):
self.error_message = (
"Missing argument exception: the argument '" + argument + "' was not found."
)
CommandlinesError.__init__(self, self.error_message)
class MissingDictionaryKeyError(CommandlinesError):
"""Missing dictionary key exception"""
def __init__(self, dict_key):
self.error_message = (
"Missing dictionary key exception: the dictionary key '"
+ dict_key
+ "' was not found."
)
CommandlinesError.__init__(self, self.error_message)
class IndexOutOfRangeError(CommandlinesError, IndexError):
"""Index out of range exception"""
def __init__(self):
self.error_message = "Index out of range exception. The requested index fell outside of the index range."
IndexError.__init__(self)
CommandlinesError.__init__(self, self.error_message)
|