From e73f10f99bd682f2cf1388f83783e50a129c72f0 Mon Sep 17 00:00:00 2001 From: Alex Pyrgiotis Date: Mon, 19 Feb 2024 20:03:38 +0200 Subject: [PATCH] Handle gracefully unknown error codes Do not throw exceptions for unknown error codes. If `get_proc_exception()` gets called from within an exception context and raises an exception itself, then this exception will not get caught, and it will get lost. Prefer instead to return an exception class that we have for this purpose, and show to the user the unknown error code of the converesion process. --- dangerzone/conversion/errors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dangerzone/conversion/errors.py b/dangerzone/conversion/errors.py index 2156087..b719e68 100644 --- a/dangerzone/conversion/errors.py +++ b/dangerzone/conversion/errors.py @@ -106,4 +106,4 @@ def exception_from_error_code( for cls in ConversionException.get_subclasses(): if cls.error_code == error_code: return cls() - raise ValueError(f"Unknown error code '{error_code}'") + return UnexpectedConversionError(f"Unknown error code '{error_code}'")