Files
docker-bridge-overlay/pkg/util/errors.go
2023-02-17 00:26:57 +01:00

25 lines
712 B
Go

package util
import (
"errors"
"net/http"
)
var (
// ErrIPAM indicates an unsupported IPAM driver was used
ErrIPAM = errors.New("only the null IPAM driver is supported")
// ErrNoContainer indicates a container was unexpectedly not found
ErrNoContainer = errors.New("couldn't find container by endpoint on the network")
// ErrGuessFailed indicates that we guessed wrong the container and docker must re-try starting us
ErrGuessFailed = errors.New("guessing of container failed containr must be re-created")
)
func ErrToStatus(err error) int {
switch {
case errors.Is(err, ErrIPAM), errors.Is(err, ErrGuessFailed):
return http.StatusBadRequest
default:
return http.StatusInternalServerError
}
}