catch ValueError, simplify try/except on top-level job runs

See https://github.com/freedomofpress/dangerzone/pull/167#discussion_r915757189
This commit is contained in:
Guthrie McAfee Armstrong 2022-09-21 13:07:54 -04:00 committed by deeplow
parent 6b44db9043
commit 9989ffea37
No known key found for this signature in database
GPG key ID: 577982871529A52A

View file

@ -369,26 +369,17 @@ def main() -> int:
converter = DangerzoneConverter()
try:
if sys.argv[1] == "document-to-pixels":
try:
job.document_to_pixels()
except (RuntimeError, TimeoutError) as e:
job.update_progress(str(e), error=True)
return 1
else:
return 0 # Success!
converter.document_to_pixels()
elif sys.argv[1] == "pixels-to-pdf":
try:
job.pixels_to_pdf()
except (RuntimeError, TimeoutError) as e:
job.update_progress(str(e), error=True)
converter.pixels_to_pdf()
except (RuntimeError, TimeoutError, ValueError) as e:
converter.update_progress(str(e), error=True)
return 1
else:
return 0 # Success!
return -1
if __name__ == "__main__":
sys.exit(main())