forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.go
51 lines (41 loc) · 1.26 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
46
47
48
49
50
51
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)
}
func ErrSocatNotFound() errors.Error {
return errors.NewError("socat not found locally").
WithDetails("socat is required to enable port forwarding\n").
WithSolution("Install socat using your package manager first\n")
}
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
}