# region Containers
[docs]class NoValidProjectError(Exception):
'''Raised when no project is found for the given identifier (which should be the name or path to the project)'''
def __init__(self, ident):
super().__init__(f'Not a valid project: {ident}')
[docs]class AmbiguousRuleError(Exception):
def __init__(self, code, text):
super().__init__(f'Can\'t combine multiple meta-rules if they require params: {code} in {text}')
# endregion
# region Artifacts
[docs]class UnknownArtifactError(Exception):
pass
[docs]class MissingArtifactError(Exception):
def __init__(self, atype, name):
super().__init__(name)
self.atype = atype
self.name = name
[docs]class MissingComponentError(MissingArtifactError):
def __init__(self, name):
super().__init__('component', name)
[docs]class MissingModifierError(MissingArtifactError):
def __init__(self, name):
super().__init__('modifier', name)
[docs]class MissingConfigError(MissingArtifactError):
def __init__(self, name):
super().__init__('config', name)
[docs]class MissingScriptError(MissingArtifactError):
def __init__(self, name):
super().__init__('script', name)
artifact_errors = {'script': MissingScriptError, 'component': MissingComponentError,
'modifier': MissingModifierError, 'config': MissingConfigError}
# endregion
# region Config
[docs]class ConfigNotFoundError(Exception):
'''Raised when a config parameter is not found and no viable defaults are provided'''
def __init__(self, ident):
super().__init__(f'Unknown config: {ident}')
[docs]class MissingParameterError(Exception):
'''Raised when a config parameter was not found, and no viable defaults were provided'''
def __init__(self, key):
super().__init__(key)
[docs]class InvalidKeyError(Exception):
'''Only raised when a key cannot be converted to an index for a :class:`ConfigList`'''
pass
[docs]class UnknownActionError(Exception):
'''Raised when trying to record an unrecognized action with the config object'''
pass
# endregion
# region Misc
[docs]class PythonizeError(Exception):
'''Raised when an object is unable to be turned into a yaml object (primitives, dicts, lists)'''
def __init__(self, obj):
super().__init__('Unable to yamlify: {} (type={})'.format(obj, type(obj)))
self.obj = obj
[docs]class WrongInfoContainerType(Exception):
'''Raised when trying to load a container, but the container expects a different type (ie. subclass).'''
def __init__(self, ctype, ctype_src=None):
super().__init__(f'Reload container using custom subclass: {ctype}')
self.ctype = ctype
self.ctype_src = ctype_src
[docs] def get_ctype(self):
return self.ctype
[docs] def get_mtype_src(self):
return self.ctype_src
[docs]class ConfigurizeFailed(Exception):
'''Raised when trying to configurize an object by type, but it ends up not working'''
pass
# endregion