Update
This commit is contained in:
1 parent
3530afb854
commit
6903fcff27
2146 files changed
+112256
-190703
No files matched your search
+16
-5
@@ -20,6 +20,10 @@ var (
|
||||
|
||||
var errNotSupported = errors.New("operation not supported")
|
||||
|
||||
// errMessageTruncated is returned when a received message was truncated
|
||||
// because the receive buffer was too small.
|
||||
var errMessageTruncated = errors.New("message truncated")
|
||||
|
||||
// notSupported provides a concise constructor for "not supported" errors.
|
||||
func notSupported(op string) error {
|
||||
return newOpError(op, errNotSupported)
|
||||
@@ -69,6 +73,11 @@ type OpError struct {
|
||||
// is not set, both of these fields will be empty.
|
||||
Message string
|
||||
Offset int
|
||||
|
||||
// Sequence is the netlink message sequence number associated with the
|
||||
// error. This field is only populated if the error was produced as the
|
||||
// result of a netlink message; otherwise, it will be zero.
|
||||
Sequence uint32
|
||||
}
|
||||
|
||||
// newOpError is a small wrapper for creating an OpError. As a convenience, it
|
||||
@@ -90,11 +99,11 @@ func (e *OpError) Error() string {
|
||||
}
|
||||
|
||||
var sb strings.Builder
|
||||
_, _ = sb.WriteString(fmt.Sprintf("netlink %s: %v", e.Op, e.Err))
|
||||
_, _ = fmt.Fprintf(&sb, "netlink %s: %v", e.Op, e.Err)
|
||||
|
||||
if e.Message != "" || e.Offset != 0 {
|
||||
_, _ = sb.WriteString(fmt.Sprintf(", offset: %d, message: %q",
|
||||
e.Offset, e.Message))
|
||||
_, _ = fmt.Fprintf(&sb, ", offset: %d, message: %q",
|
||||
e.Offset, e.Message)
|
||||
}
|
||||
|
||||
return sb.String()
|
||||
@@ -115,7 +124,8 @@ type timeout interface {
|
||||
|
||||
// Timeout reports whether the error was caused by an I/O timeout.
|
||||
func (e *OpError) Timeout() bool {
|
||||
if ne, ok := e.Err.(*os.SyscallError); ok {
|
||||
ne := &os.SyscallError{}
|
||||
if errors.As(e.Err, &ne) {
|
||||
t, ok := ne.Err.(timeout)
|
||||
return ok && t.Timeout()
|
||||
}
|
||||
@@ -129,7 +139,8 @@ type temporary interface {
|
||||
|
||||
// Temporary reports whether an operation may succeed if retried.
|
||||
func (e *OpError) Temporary() bool {
|
||||
if ne, ok := e.Err.(*os.SyscallError); ok {
|
||||
ne := &os.SyscallError{}
|
||||
if errors.As(e.Err, &ne) {
|
||||
t, ok := ne.Err.(temporary)
|
||||
return ok && t.Temporary()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user