diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-03-25 19:42:20 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-03-25 19:42:20 +0900 |
| commit | f86d8682749dda2d0f6dc62d493389a5e0c8d88d (patch) | |
| tree | 66f7d9564545bbd790a12176cb3802959ba66389 /sandbox/path.go | |
| parent | 33940265a6c193fe024ad11b8c61a2869ef858d9 (diff) | |
sandbox: wrap error with its own text message
PathError has a pretty good text message, many of them are wrapped with its own text message. This change adds a function to do just that to improve readability.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'sandbox/path.go')
| -rw-r--r-- | sandbox/path.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/sandbox/path.go b/sandbox/path.go index bc400267..2517bfb1 100644 --- a/sandbox/path.go +++ b/sandbox/path.go @@ -32,16 +32,16 @@ func toHost(name string) string { func createFile(name string, perm, pperm os.FileMode, content []byte) error { if err := os.MkdirAll(path.Dir(name), pperm); err != nil { - return msg.WrapErr(err, err.Error()) + return wrapErrSelf(err) } f, err := os.OpenFile(name, syscall.O_CREAT|syscall.O_EXCL|syscall.O_WRONLY, perm) if err != nil { - return msg.WrapErr(err, err.Error()) + return wrapErrSelf(err) } if content != nil { _, err = f.Write(content) if err != nil { - err = msg.WrapErr(err, err.Error()) + err = wrapErrSelf(err) } } return errors.Join(f.Close(), err) @@ -78,7 +78,7 @@ func (p *procPaths) stdout() string { return p.self + "/fd/1" } func (p *procPaths) fd(fd int) string { return p.self + "/fd/" + strconv.Itoa(fd) } func (p *procPaths) mountinfo(f func(d *vfs.MountInfoDecoder) error) error { if r, err := os.Open(p.self + "/mountinfo"); err != nil { - return msg.WrapErr(err, err.Error()) + return wrapErrSelf(err) } else { d := vfs.NewMountInfoDecoder(r) err0 := f(d) |
