error_posix.go 624 B

123456789101112131415161718192021
  1. // Copyright 2017 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. //go:build aix || darwin || dragonfly || freebsd || hurd || (js && wasm) || linux || netbsd || openbsd || solaris || windows
  5. package net
  6. import (
  7. "os"
  8. "syscall"
  9. )
  10. // wrapSyscallError takes an error and a syscall name. If the error is
  11. // a syscall.Errno, it wraps it in a os.SyscallError using the syscall name.
  12. func wrapSyscallError(name string, err error) error {
  13. if _, ok := err.(syscall.Errno); ok {
  14. err = os.NewSyscallError(name, err)
  15. }
  16. return err
  17. }