Source code for auxlib.exceptions

# -*- coding: utf-8 -*-
from logging import getLogger

log = getLogger(__name__)


[docs]def Raise(exception): # NOQA raise exception
[docs]class AuxlibError(object): """Mixin to identify exceptions associated with the auxlib package."""
[docs]class AuthenticationError(AuxlibError, ValueError): pass
[docs]class NotFoundError(AuxlibError, KeyError): pass
[docs]class InitializationError(AuxlibError, EnvironmentError): pass
[docs]class SenderError(AuxlibError, IOError): pass
[docs]class AssignmentError(AuxlibError, AttributeError): pass
[docs]class ValidationError(AuxlibError, TypeError): def __init__(self, key, value=None, valid_types=None, msg=None): self.__cause__ = None # in python3 don't chain ValidationError exceptions if msg is not None: super(ValidationError, self).__init__(msg) elif value is None: super(ValidationError, self).__init__("Value for {0} cannot be None." "".format(key)) elif valid_types is None: super(ValidationError, self).__init__("Invalid value {0} for {1}" "".format(value, key)) else: super(ValidationError, self).__init__("{0} must be of type {1}, not {2}" "".format(key, valid_types, repr(value)))
[docs]class ThisShouldNeverHappenError(AuxlibError, AttributeError): pass