backups: Adjust to changes in privileged errors

Tests:

- Unit tests requiring root succeed.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2024-03-18 14:34:32 -07:00 committed by James Valleroy
parent ade2d0c8f2
commit c855640f84
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -275,7 +275,9 @@ class BaseBorgRepository(abc.ABC):
@staticmethod
def reraise_known_error(err):
"""Look whether the caught error is known and reraise it accordingly"""
caught_error = str((err, err.args))
stdout = getattr(err, 'stdout', b'').decode()
stderr = getattr(err, 'stderr', b'').decode()
caught_error = str((err, err.args, stdout, stderr))
for known_error in KNOWN_ERRORS:
for error in known_error['errors']:
if re.search(error, caught_error):