libnetwork/types: remove ErrInvalidProtocolBinding

It was not used as a sentinel error, and didn't carry a specific type,
which made it a rather complex way to create an error.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2023-07-29 02:31:26 +02:00
parent 4445169cb5
commit d9b7a5f01a
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -86,7 +86,7 @@ func (p PortBinding) HostAddr() (net.Addr, error) {
case SCTP:
return &sctp.SCTPAddr{IPAddrs: []net.IPAddr{{IP: p.HostIP}}, Port: int(p.HostPort)}, nil
default:
return nil, ErrInvalidProtocolBinding(p.Proto.String())
return nil, fmt.Errorf("invalid transport protocol: %s", p.Proto.String())
}
}
@ -100,7 +100,7 @@ func (p PortBinding) ContainerAddr() (net.Addr, error) {
case SCTP:
return &sctp.SCTPAddr{IPAddrs: []net.IPAddr{{IP: p.IP}}, Port: int(p.Port)}, nil
default:
return nil, ErrInvalidProtocolBinding(p.Proto.String())
return nil, fmt.Errorf("invalid transport protocol: %s", p.Proto.String())
}
}
@ -130,13 +130,6 @@ func (p *PortBinding) String() string {
return ret
}
// ErrInvalidProtocolBinding is returned when the port binding protocol is not valid.
type ErrInvalidProtocolBinding string
func (ipb ErrInvalidProtocolBinding) Error() string {
return fmt.Sprintf("invalid transport protocol: %s", string(ipb))
}
const (
// ICMP is for the ICMP ip protocol
ICMP = 1