From 16603875d679534870e2c148218473ebe66eb9ef Mon Sep 17 00:00:00 2001 From: Alex Pyrgiotis Date: Mon, 2 Oct 2023 15:25:55 +0300 Subject: [PATCH] qubes: Display all errors in second stage If a command encounters an error or times out during the second stage of the conversion in Qubes, handle it the same way as we would have handled it in the first stage: 1. Get its error message. 2. Throw an UnexpectedConversionError exception, with the original message. Note that, because the second stage takes place locally, users will see the original content of the error. Refs #567 Closes #430 --- dangerzone/isolation_provider/qubes.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dangerzone/isolation_provider/qubes.py b/dangerzone/isolation_provider/qubes.py index 8c6429d..58baec1 100644 --- a/dangerzone/isolation_provider/qubes.py +++ b/dangerzone/isolation_provider/qubes.py @@ -162,9 +162,11 @@ class Qubes(IsolationProvider): def print_progress_wrapper(error: bool, text: str, percentage: float) -> None: self.print_progress_trusted(document, error, text, percentage) - asyncio.run( - PixelsToPDF(progress_callback=print_progress_wrapper).convert(ocr_lang) - ) + converter = PixelsToPDF(progress_callback=print_progress_wrapper) + try: + asyncio.run(converter.convert(ocr_lang)) + except (RuntimeError, TimeoutError, ValueError) as e: + raise errors.UnexpectedConversionError(str(e)) shutil.move(CONVERTED_FILE_PATH, document.output_filename) success = True