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
This commit is contained in:
Alex Pyrgiotis 2023-10-02 15:25:55 +03:00
parent 2016965c84
commit 16603875d6
No known key found for this signature in database
GPG key ID: B6C15EBA0357C9AA

View file

@ -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