##########################################################################
# NSAp - Copyright (C) CEA, 2017
# Distributed under the terms of the CeCILL-B license, as published by
# the CEA-CNRS-INRIA. Refer to the LICENSE file or to
# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
# for details.
##########################################################################


class ANTSError(Exception):
    """ Base exception type for the package.
    """
    def __init__(self, message):
        super(ANTSError, self).__init__(message)


class ANTSRuntimeError(ANTSError):
    """ Error thrown when call to the ANTS software failed.
    """
    def __init__(self, algorithm_name, parameters, error=None):
        message = (
            "ANTS call for '{0}' failed, with parameters: '{1}'. Error:: "
            "{2}.".format(algorithm_name, parameters, error))
        super(ANTSRuntimeError, self).__init__(message)


class ANTSConfigurationError(ANTSError):
    """ Error thrown when call to the ANTS software failed.
    """
    def __init__(self, command_name):
        message = "ANTS command '{0}' not found.".format(command_name)
        super(ANTSConfigurationError, self).__init__(message)


class ANTSResultError(ANTSError):
    """ Error thrown when the ANTS software has returned a strange result.
    """
    def __init__(self, command):
        message = ("ANTS command '{0}' may have returned a strange "
                   "result.".format(command))
        super(ANTSResultError, self).__init__(message)


class ANTSDependencyError(ANTSError):
    """ Error thrown when the ANTS software needs a dependency.
    """
    def __init__(self, command, package_name):
        message = ("ANTS software uses {0}. Please make sure that {1} package "
                   "is installed ".format(command, package_name))
        super(ANTSDependencyError, self).__init__(message)
