from typing import Optional

from messageprocessor import MessageProcessorCallback


class ExceptionProcessorCallback(MessageProcessorCallback):
    def __init__(self):
        self.exception: Optional[Exception] = None

    def process_begun(
        self,
        event_name,
        request_id,
        **kwargs
    ):
        return

    def input_parsed(
        self,
        event_name,
        request_id,
        input_obj
    ):
        return

    def business_called(
        self,
        event_name,
        request_id,
        input_obj,
        output_obj
    ):
        return

    def process_finished(
        self,
        event_name,
        request_id,
        input_obj,
        output_obj
    ):
        return

    def parse_exception(
        self,
        event_name,
        request_id,
        data,
        exception
    ):
        self.exception = exception

    def unhandled_exception(
        self,
        event_name,
        request_id,
        input_obj,
        exception
    ):
        self.exception = exception
