diff --git a/docs/release_notes.rst b/docs/release_notes.rst index fc16485e..5ba92c1b 100644 --- a/docs/release_notes.rst +++ b/docs/release_notes.rst @@ -50,6 +50,8 @@ v15.4.0 rather than fork, since this is method is more robust and avoids some issues when threads are present. - Fixed an instance where the user's request to ``--no-use-threads`` was ignored. +- If a PDF does not have language metadata on its top level object, we add + the OCR language. - Replace some cryptic test error messages with more helpful ones. - Debug messages for how OCRmyPDF picks the colorspace for a page are now more descriptive. diff --git a/src/ocrmypdf/_pipelines/_common.py b/src/ocrmypdf/_pipelines/_common.py index 0ebcb329..4113cd26 100644 --- a/src/ocrmypdf/_pipelines/_common.py +++ b/src/ocrmypdf/_pipelines/_common.py @@ -229,7 +229,17 @@ def cli_exception_handler( options: argparse.Namespace, plugin_manager: OcrmypdfPluginManager, ) -> ExitCode: + """Convert exceptions into command line error messages and exit codes. + + When known exceptions are raised, the exception message is printed to stderr + and the program exits with a non-zero exit code. When unknown exceptions are + raised, the exception traceback is printed to stderr and the program exits + with a non-zero exit code. + """ try: + # We cannot use a generator and yield here, as would be the usual pattern + # for exception handling context managers, because we need to return an exit + # code. return fn(options, plugin_manager) except KeyboardInterrupt: if options.verbose >= 1: