diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-08-30 23:44:48 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-08-30 23:44:48 +0900 |
| commit | 712cfc06d7e541c6e28b4b127a4760b4cfccffa8 (patch) | |
| tree | 3dbd2bc0fc03ba5d108646b342392f5fdf841c90 /container/params.go | |
| parent | f5abce9df5727904a1daa246025a87c4bfe62553 (diff) | |
container: wrap container init start errors
This helps indicate the exact origin and nature of the error. This eliminates generic WrapErr from container.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'container/params.go')
| -rw-r--r-- | container/params.go | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/container/params.go b/container/params.go index 00c98cf8..f9862a19 100644 --- a/container/params.go +++ b/container/params.go @@ -8,11 +8,6 @@ import ( "syscall" ) -var ( - ErrNotSet = errors.New("environment variable not set") - ErrFdFormat = errors.New("bad file descriptor representation") -) - // Setup appends the read end of a pipe for setup params transmission and returns its fd. func Setup(extraFiles *[]*os.File) (int, *gob.Encoder, error) { if r, w, err := os.Pipe(); err != nil { @@ -24,19 +19,23 @@ func Setup(extraFiles *[]*os.File) (int, *gob.Encoder, error) { } } +var ( + ErrReceiveEnv = errors.New("environment variable not set") +) + // Receive retrieves setup fd from the environment and receives params. func Receive(key string, e any, fdp *uintptr) (func() error, error) { var setup *os.File if s, ok := os.LookupEnv(key); !ok { - return nil, ErrNotSet + return nil, ErrReceiveEnv } else { if fd, err := strconv.Atoi(s); err != nil { - return nil, ErrFdFormat + return nil, errors.Unwrap(err) } else { setup = os.NewFile(uintptr(fd), "setup") if setup == nil { - return nil, syscall.EBADF + return nil, syscall.EDOM } if fdp != nil { *fdp = setup.Fd() |
