Skip to content

Commit 169a2d7

Browse files
committed
net: add wrapSyscallError
Signed-off-by: Roman Volosatovs <[email protected]>
1 parent 1b79a98 commit 169a2d7

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/net/error_posix.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// The following is copied and adapted from Go 1.18 official implementation.
2+
3+
// Copyright 2017 The Go Authors. All rights reserved.
4+
// Use of this source code is governed by a BSD-style
5+
// license that can be found in the LICENSE file.
6+
7+
//go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris || windows || wasi
8+
// +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solaris windows wasi
9+
10+
package net
11+
12+
import (
13+
"os"
14+
"syscall"
15+
)
16+
17+
// wrapSyscallError takes an error and a syscall name. If the error is
18+
// a syscall.Errno, it wraps it in a os.SyscallError using the syscall name.
19+
func wrapSyscallError(name string, err error) error {
20+
if _, ok := err.(syscall.Errno); ok {
21+
err = os.NewSyscallError(name, err)
22+
}
23+
return err
24+
}

0 commit comments

Comments
 (0)