"""
Protected module contains job error class
"""

from dataclasses import dataclass

__all__ = []


@dataclass
class JobError:
    """A single error entry returned by the enaio server in a job response.

    Known error codes:

    - ``-1043332470``: Missing request parameter.

    Args:
        source (str): Source module or component where the error occurred.
        message (str): Human-readable error message from the API.
        source_code (int): Numeric source identifier reported by the server.
        error_code (int): Numeric error code from the API.
        infos (list[str]): Additional details such as a stack trace or context information.
    """

    source: str
    message: str
    source_code: int
    error_code: int
    infos: list[str]

    def __str__(self) -> str:
        return f"({self.source}) : {self.error_code} = {self.message}" + "\n".join(self.infos)
