"""This module holds the exception for the ``translation`` app."""


class PoFileCheckError(Exception):
    """Exception raised when a check on a ``PO`` file failed.

    Attributes
    ----------
    errors : list(tuple(None|POEntry, str))
        Instance attribute that will contain all the errors found in a pofile.
        Each entry is a tuple with two entries:
        - The ``POEntry`` of the ``POFile`` that generated the error, or ``None`` if the error
          was not tied to such an object
        - The error message returned by ``msgfmt``
    fatal : bool, default to ``False``
        If the check of the ``POFile`` generated an error not tied to a ``POEntry``, this flag
        will be set to ``True``. If ``False``, all errors in ``errors`` are tied to a ``POEntry``.

    """

    def __init__(self, errors, fatal=False):
        super().__init__('This PO file is not valid')
        self.errors = errors
        self.fatal = fatal
