pycriu: better socket error handling

[Errno 2] No such file or directory -> Socket file not found.
[Errno 111] Connection refused -> Service not running.

Signed-off-by: Andrii Herheliuk <andrii@herheliuk.com>
This commit is contained in:
Andrii Herheliuk 2025-10-23 10:50:40 +01:00 committed by Andrei Vagin
parent 7aad7317b4
commit d2c46b92b0

View file

@ -45,7 +45,14 @@ class _criu_comm_sk(_criu_comm):
def connect(self, daemon):
self.sk = socket.socket(socket.AF_UNIX, socket.SOCK_SEQPACKET)
self.sk.connect(self.comm)
try:
self.sk.connect(self.comm)
except FileNotFoundError:
raise FileNotFoundError("Socket file not found.")
except ConnectionRefusedError:
raise ConnectionRefusedError("Service not running.")
return self.sk