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.
This commit is contained in:
Alex Pyrgiotis 2024-02-19 20:03:38 +02:00
parent aeb8c33b6e
commit e73f10f99b
No known key found for this signature in database
GPG key ID: B6C15EBA0357C9AA

View file

@ -106,4 +106,4 @@ def exception_from_error_code(
for cls in ConversionException.get_subclasses(): for cls in ConversionException.get_subclasses():
if cls.error_code == error_code: if cls.error_code == error_code:
return cls() return cls()
raise ValueError(f"Unknown error code '{error_code}'") return UnexpectedConversionError(f"Unknown error code '{error_code}'")