pycriu: prevent always appending "Unknown" to error messages

Regardless of the actual error message, "Unknown" was always appended
to the end of the string, resulting in messages like:
"DUMP failed: Error(3): No process with such pidUnknown".

Fixed by changing standalone if statements to else-if blocks so
"Unknown" is only added when no specific error condition matches.

Signed-off-by: Andrii Herheliuk <andrii@herheliuk.com>
This commit is contained in:
Andrii Herheliuk 2025-10-18 04:00:08 +01:00 committed by Andrei Vagin
parent 540c631dd0
commit d5c81f8108

View file

@ -181,15 +181,14 @@ class CRIUExceptionExternal(CRIUException):
if self.errno == errno.EBADRQC:
s += "Bad options"
if self.typ == rpc.DUMP:
if self.errno == errno.ESRCH:
s += "No process with such pid"
elif self.typ == rpc.DUMP and self.errno == errno.ESRCH:
s += "No process with such pid"
if self.typ == rpc.RESTORE:
if self.errno == errno.EEXIST:
s += "Process with requested pid already exists"
elif self.typ == rpc.RESTORE and self.errno == errno.EEXIST:
s += "Process with requested pid already exists"
s += "Unknown"
else:
s += "Unknown"
return s