aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/system
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-12-07 02:08:05 +0900
committerOphestra <cat@gensokyo.uk>2025-12-07 02:08:05 +0900
commit246e04214a3554826be1f4285f56044b0850102d (patch)
tree2cb62325dc87a8f4eec9eab04e731b86c16af797 /internal/system
parent503bfc64689ebf90ab54e59593976876600c4b9b (diff)
internal/system: pass syscall error message
This makes wrapped syscall errors produce a cleaner error message. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/system')
-rw-r--r--internal/system/output.go1
-rw-r--r--internal/system/output_test.go5
2 files changed, 6 insertions, 0 deletions
diff --git a/internal/system/output.go b/internal/system/output.go
index a1666dc3..80ab88ed 100644
--- a/internal/system/output.go
+++ b/internal/system/output.go
@@ -26,6 +26,7 @@ func (e *OpError) Error() string {
switch {
case errors.As(e.Err, new(*os.PathError)),
errors.As(e.Err, new(*os.LinkError)),
+ errors.As(e.Err, new(*os.SyscallError)),
errors.As(e.Err, new(*net.OpError)),
errors.As(e.Err, new(*container.StartError)):
return e.Err.Error()
diff --git a/internal/system/output_test.go b/internal/system/output_test.go
index c0cbfdfe..54d12254 100644
--- a/internal/system/output_test.go
+++ b/internal/system/output_test.go
@@ -44,6 +44,11 @@ func TestOpError(t *testing.T) {
syscall.EISDIR, syscall.ENOTDIR,
"cannot stat /run/dbus: is a directory"},
+ {"syscall", newOpError("pipewire", os.NewSyscallError("pipe2", syscall.ENOTRECOVERABLE), false),
+ "pipe2: state not recoverable",
+ syscall.ENOTRECOVERABLE, syscall.ENOTDIR,
+ "cannot pipe2: state not recoverable"},
+
{"net", newOpError("wayland", &net.OpError{Op: "dial", Net: "unix", Addr: &net.UnixAddr{Name: "/run/user/1000/wayland-1", Net: "unix"}, Err: syscall.ENOENT}, false),
"dial unix /run/user/1000/wayland-1: no such file or directory",
syscall.ENOENT, syscall.EPERM,