system/output: pass through LinkError
All checks were successful
Test / Create distribution (push) Successful in 35s
Test / Sandbox (push) Successful in 2m50s
Test / Sandbox (race detector) (push) Successful in 4m54s
Test / Hpkg (push) Successful in 5m16s
Test / Hakurei (race detector) (push) Successful in 5m51s
Test / Hakurei (push) Successful in 2m57s
Test / Flake checks (push) Successful in 2m10s

This has similar formatting to PathError.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
Ophestra 2025-09-06 17:41:06 +09:00
parent e68db7fbfc
commit fcd0f2ede7
Signed by: cat
SSH Key Fingerprint: SHA256:gQ67O0enBZ7UdZypgtspB2FDM1g3GVw8nX0XSdcFw8Q
2 changed files with 7 additions and 14 deletions

View File

@ -34,6 +34,7 @@ func (e *OpError) Error() string {
switch { switch {
case errors.As(e.Err, new(*os.PathError)), case errors.As(e.Err, new(*os.PathError)),
errors.As(e.Err, new(*os.LinkError)),
errors.As(e.Err, new(*net.OpError)), errors.As(e.Err, new(*net.OpError)),
errors.As(e.Err, new(*container.StartError)): errors.As(e.Err, new(*container.StartError)):
return e.Err.Error() return e.Err.Error()

View File

@ -137,22 +137,14 @@ func TestPrintJoinedError(t *testing.T) {
{"file descriptor in bad state"}, {"file descriptor in bad state"},
}}, }},
{"many message", errors.Join( {"many message", errors.Join(
&container.StartError{ &container.StartError{Step: "meow", Err: syscall.ENOMEM},
Step: "meow", &os.PathError{Op: "meow", Path: "/proc/nonexistent", Err: syscall.ENOSYS},
Err: syscall.ENOMEM, &os.LinkError{Op: "link", Old: "/etc", New: "/proc/nonexistent", Err: syscall.ENOENT},
}, &OpError{Op: "meow", Err: syscall.ENODEV, Revert: true},
&os.PathError{ ), [][]any{
Op: "meow",
Path: "/proc/nonexistent",
Err: syscall.ENOSYS,
},
&OpError{
Op: "meow",
Err: syscall.ENODEV,
Revert: true,
}), [][]any{
{"cannot meow: cannot allocate memory"}, {"cannot meow: cannot allocate memory"},
{"meow /proc/nonexistent: function not implemented"}, {"meow /proc/nonexistent: function not implemented"},
{"link /etc /proc/nonexistent: no such file or directory"},
{"cannot revert meow: no such device"}, {"cannot revert meow: no such device"},
}}, }},
} }