"""
AA Intel Tool exceptions
"""

# Django
from django.utils.translation import gettext_lazy as _


class AaIntelToolException(Exception):
    """
    An exception generated by AA Intel Tool.
    """


class ParserError(AaIntelToolException):
    """
    Parser Error raised for errors within our parsers
    """

    def __init__(self, message: str) -> None:
        super().__init__(message)

        self._message = message

    @property
    def message(self) -> str:
        """
        Message of the error.

        :return:
        :rtype:
        """

        return self._message

    def __str__(self) -> str:
        """
        String representation of the error.

        :return:
        :rtype:
        """

        message = self.message if self.message else _("Unknown parser error")

        return str(_(f"A parser error occurred » {message}"))
