exceptions: define format in ABC
This commit is contained in:
parent
702b160c93
commit
1295bf1ec5
@ -1,6 +1,5 @@
|
||||
|
||||
class ConfigError(Exception):
|
||||
|
||||
"""ABC for configuration exceptions"""
|
||||
|
||||
def __init__(self, module, *args, **kwargs):
|
||||
@ -9,26 +8,25 @@ class ConfigError(Exception):
|
||||
|
||||
super().__init__(message)
|
||||
|
||||
def format(self, *args, **kwargs):
|
||||
return ""
|
||||
|
||||
|
||||
class ConfigKeyError(ConfigError, KeyError):
|
||||
|
||||
def format(self, key):
|
||||
return "invalid option '{0}'".format(key)
|
||||
|
||||
|
||||
class ConfigMissingError(ConfigError):
|
||||
|
||||
def format(self, missing):
|
||||
return "missing required options: {0}".format(missing)
|
||||
|
||||
|
||||
class ConfigAmbigiousClassesError(ConfigError):
|
||||
|
||||
def format(self, ambigious_classes):
|
||||
return "ambigious module specification, found multiple classes: {0}".format(ambigious_classes)
|
||||
|
||||
|
||||
class ConfigInvalidModuleError(ConfigError):
|
||||
|
||||
def format(self):
|
||||
return "no class found"
|
||||
|
Loading…
Reference in New Issue
Block a user