Rearrange error handling

Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
This commit is contained in:
Nicola Guerrera 2024-01-27 12:08:16 +01:00 committed by GitHub
parent 1522b3fb84
commit 6998f34768
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -171,7 +171,9 @@ def grabclipboard():
err = p.stderr
if any(e in err for e in allowed_errors):
return None
msg = f"{args[0]} error: {err.strip().decode() if err else 'Unknown error'}"
msg = f"{args[0]} error"
if err:
msg += f": {err.strip().decode()}"
raise ChildProcessError(msg)
data = io.BytesIO(p.stdout)