from exceptions import Exception


class CheckerBaseExceptions(Exception):
    pass


class CheckerException(CheckerBaseExceptions):
    def __init__(self, message, *args, **kwargs):
        super(CheckerException, self).__init__(message, *args, **kwargs)
        # get the trace
        # TODO: get and log traceback

        # prettify message
        self.message = "# CheckerException: {}".format(message)


class ConfigException(CheckerException):
    def __init__(self, message, *args, **kwargs):
        super(ConfigException, self).__init__(message, *args, **kwargs)
        self.message = "# Configuration error: {}".format(message)


class SaltException(CheckerException):
    def __init__(self, message, *args, **kwargs):
        super(SaltException, self).__init__(message, *args, **kwargs)
        self.message = "# Salt error: {}".format(message)


class InvalidReturnException(CheckerException):
    def __init__(self, message, *args, **kwargs):
        super(InvalidReturnException, self).__init__(message, *args, **kwargs)
        self.message = "# Unexpected return value: {}".format(message)
