from pipelex.base_exceptions import PipelexError
from pipelex.pipe_run.pipe_run_mode import PipeRunMode


class PipeRunParamsError(PipelexError):
    pass


class BatchParamsError(PipelexError):
    pass


class PipeRunError(PipelexError):
    def __init__(self, message: str, run_mode: PipeRunMode, pipe_code: str):
        self.run_mode = run_mode
        self.pipe_code = pipe_code
        super().__init__(message)


class PipeJobError(PipelexError):
    pass


class DeliveryError(PipelexError):
    pass


class WebhookDeliveryError(DeliveryError):
    pass


class StorageDeliveryError(DeliveryError):
    pass


class PipeRouterError(PipelexError):
    def __init__(
        self,
        message: str,
        run_mode: PipeRunMode,
        pipe_code: str,
        output_name: str | None,
        pipe_stack: list[str],
        missing_inputs: list[str] | None = None,
    ):
        self.run_mode = run_mode
        self.pipe_code = pipe_code
        self.output_name = output_name
        self.pipe_stack = list(pipe_stack)  # snapshot: the live stack unwinds after this error is raised
        self.missing_inputs = missing_inputs
        super().__init__(message)
