Skip to content

Surface umount stderr in UnmountError; user-friendly error messages in backup/close - #145

Open
MaxG87 with Copilot wants to merge 8 commits into
mainfrom
copilot/attach-umount-error-message
Open

Surface umount stderr in UnmountError; user-friendly error messages in backup/close#145
MaxG87 with Copilot wants to merge 8 commits into
mainfrom
copilot/attach-umount-error-message

Conversation

Copilot AI commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

umount failures previously surfaced as an unhandled UnmountError stack trace with no context (e.g. "target is busy" when a shell is open on the device). This change propagates the umount stderr to the user as a plain error message.

shell_interface: add stderr to ShellInterfaceError

ShellInterfaceError now carries the stderr bytes from the underlying CalledProcessError, defaulting to b"" when output wasn't captured:

class ShellInterfaceError(RuntimeError):
    def __init__(self, msg: str, stderr: bytes = b"") -> None:
        super().__init__(msg)
        self.stderr = stderr

Both run_cmd and pipe_pass_cmd_to_real_cmd populate it on failure.

storage_device_managers: propagate stderr into UnmountError

unmount_device now runs umount with capture_output=True and attaches the decoded stderr directly to the UnmountError message — no more isinstance/__cause__ chain:

except sh.ShellInterfaceError as e:
    raise UnmountError(e.stderr.decode(errors="replace").strip()) from e

butter_backup CLI: catch UnmountError in backup and close

Both commands now catch UnmountError and print a human-readable message to stderr instead of letting the exception propagate. backup continues processing remaining devices and exits with code 1 after the loop if any unmount failed.

@MaxG87
MaxG87 force-pushed the copilot/attach-umount-error-message branch 3 times, most recently from 009d093 to 22d3a50 Compare August 17, 2026 16:42
Copilot AI requested a review from MaxG87 August 17, 2026 16:47
@MaxG87
MaxG87 force-pushed the copilot/attach-umount-error-message branch 2 times, most recently from a384425 to 1b0e9b6 Compare August 22, 2026 21:13
@MaxG87
MaxG87 marked this pull request as ready for review August 23, 2026 20:18
MaxG87 added 3 commits August 24, 2026 21:48
Users do not want to see a stack trace in case the device could not be
unmounted. Instead, they'd prefer to get a useful error message without
scrolling. This new feature will provide that.
…nt error

Co-authored-by: MaxG87 <5477952+MaxG87@users.noreply.github.com>
The receiver of the exception can decide on their own what to do about
this. There is no need to formulate the error message at the error site.
MaxG87 and others added 3 commits August 25, 2026 08:33
Instead of putting the complete exception to the string, only the STDERR
is given now. This reduces the error message to the necessary
information.
If frozen, the traceback cannot be set, which causes the error handling
to crash itself.
Co-authored-by: MaxG87 <5477952+MaxG87@users.noreply.github.com>
Copilot AI and others added 2 commits August 25, 2026 08:45
Co-authored-by: MaxG87 <5477952+MaxG87@users.noreply.github.com>
Co-authored-by: MaxG87 <5477952+MaxG87@users.noreply.github.com>
@MaxG87
MaxG87 force-pushed the copilot/attach-umount-error-message branch from 60a8126 to d74317e Compare August 25, 2026 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants