def set_error_handler(
        self,
        error_handler: Callable[[str, PipeCallable, List[Doc], Exception], NoReturn],
    ):
        """Set an error handler object for all the components in the pipeline
        that implement a set_error_handler function.

        error_handler (Callable[[str, Callable[[Doc], Doc], List[Doc], Exception], NoReturn]):
            Function that deals with a failing batch of documents. This callable
            function should take in the component's name, the component itself,
            the offending batch of documents, and the exception that was thrown.
        DOCS: https://spacy.io/api/language#set_error_handler
        """
        self.default_error_handler = error_handler
        for name, pipe in self.pipeline:
            if hasattr(pipe, "set_error_handler"):
                pipe.set_error_handler(error_handler)
Set an error handler object for all the components in the pipeline
        that implement a set_error_handler function.

        error_handler (Callable[[str, Callable[[Doc], Doc], List[Doc], Exception], NoReturn]):
            Function that deals with a failing batch of documents. This callable
            function should take in the component's name, the component itself,
            the offending batch of documents, and the exception that was thrown.
        DOCS: https://spacy.io/api/language#set_error_handler
        
spacy/language.py