error_unix_test.go 762 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright 2015 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 !plan9 && !windows
  5. package net
  6. import (
  7. "errors"
  8. "os"
  9. "syscall"
  10. )
  11. var (
  12. errTimedout = syscall.ETIMEDOUT
  13. errOpNotSupported = syscall.EOPNOTSUPP
  14. abortedConnRequestErrors = []error{syscall.ECONNABORTED} // see accept in fd_unix.go
  15. )
  16. func isPlatformError(err error) bool {
  17. _, ok := err.(syscall.Errno)
  18. return ok
  19. }
  20. func samePlatformError(err, want error) bool {
  21. if op, ok := err.(*OpError); ok {
  22. err = op.Err
  23. }
  24. if sys, ok := err.(*os.SyscallError); ok {
  25. err = sys.Err
  26. }
  27. return err == want
  28. }
  29. func isENOBUFS(err error) bool {
  30. return errors.Is(err, syscall.ENOBUFS)
  31. }