AdGuardHome/internal/dhcpd/conn_unix.go
Ainar Garipov 05262d7b6b Pull request 1962: upd-code-deps
Squashed commit of the following:

commit 7a24cf8f9c5515f642cbfc7e730b95005eeab11d
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Tue Aug 15 14:54:16 2023 +0300

    all: upd code, deps, tools
2023-08-15 15:09:08 +03:00

24 lines
645 B
Go

//go:build darwin || freebsd || linux || openbsd
package dhcpd
import (
"fmt"
"github.com/AdguardTeam/golibs/errors"
)
// wrapErrs is a helper to wrap the errors from two independent underlying
// connections.
func wrapErrs(action string, udpConnErr, rawConnErr error) (err error) {
switch {
case udpConnErr != nil && rawConnErr != nil:
return fmt.Errorf("%s both connections: %s", action, errors.Join(udpConnErr, rawConnErr))
case udpConnErr != nil:
return fmt.Errorf("%s udp connection: %w", action, udpConnErr)
case rawConnErr != nil:
return fmt.Errorf("%s raw connection: %w", action, rawConnErr)
default:
return nil
}
}