#!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
.. module:: error
   :synopsis: Project specific exception classes.

.. moduleauthor:: Jiri Mikulka <jiri.mikulka@gmail.com>

"""


class HPNIError(Exception):
    """
    General purpose exception class.

    General purpose exception class, derived from Python's exception,
    from which other project specific classes inherit.

    Attributes
    ----------
    message : str
        Error message.

    """

    message = None

    def __str__(self):
        """
        Human readable error message.

        Create a human readable error message starting with the error type,
        followed by the issue explanation.

        Returns
        -------
        str
            Human readable and understandable error message.

        """

        return "{}: {}".format(self.__class__.__name__, self.message)


class IntegralError(HPNIError):
    """
    Integral format related errors.

    """

    message = "invalid function format"


class VariableError(HPNIError):
    """
    General error for all problems with variables.

    """

    message = "invalid variable specification"


class VariableNameError(VariableError):
    """
    Wrong variable name error.

    """

    message = "invalid variable name"


class VariableBoundsError(VariableError):
    """
    Corrupted variable boundaries format.

    """

    message = "invalid variable boundaries"


class VariableStepError(VariableError):
    """
    Corrupted variable step format.

    """

    message = "invalid variable step"


class PrecisionError(HPNIError):
    """
    Corrupted precision format.

    """

    message = "invalid precision format"


class DigitsError(HPNIError):
    """
    Corrupted decimal digits format.

    """

    message = "invalid digits format"


class NumberError(HPNIError):
    """
    General error for all issues with wrong number format.

    """

    message = "invalid number format"


class TKSLError(HPNIError):
    """
    Problems related to external TKSL program.

    """

    message = "problem with TKSL occurred"


class NumMethodError(HPNIError):
    """
    All problems during numerical derivation and integration.

    """

    message = "problem during numerical computation occurred"


class StepTooBigError(HPNIError):
    """
    Signal for halving the step for numerical method.

    """

    message = "step is too large, need to halve it and start again"
