forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.go
45 lines (36 loc) · 1.04 KB
/
errors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package openshift
import (
"fmt"
"github.com/openshift/origin/pkg/bootstrap/docker/errors"
)
// ErrOpenShiftFailedToStart is thrown when the OpenShift server failed to start
func ErrOpenShiftFailedToStart(container string) errors.Error {
return errors.NewError("could not start OpenShift container %q", container)
}
// ErrTimedOutWaitingForStart is thrown when the OpenShift server can't be pinged after reasonable
// amount of time.
func ErrTimedOutWaitingForStart(container string) errors.Error {
return errors.NewError("timed out waiting for OpenShift container %q", container)
}
type errPortsNotAvailable struct {
ports []int
}
func (e *errPortsNotAvailable) Error() string {
return fmt.Sprintf("ports in use: %v", e.ports)
}
func ErrPortsNotAvailable(ports []int) error {
return &errPortsNotAvailable{
ports: ports,
}
}
func IsPortsNotAvailableErr(err error) bool {
_, ok := err.(*errPortsNotAvailable)
return ok
}
func UnavailablePorts(err error) []int {
e, ok := err.(*errPortsNotAvailable)
if !ok {
return []int{}
}
return e.ports
}