forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
errors.go
39 lines (34 loc) · 877 Bytes
/
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
package run
import (
"bytes"
"fmt"
"github.com/docker/engine-api/types/container"
"github.com/openshift/origin/pkg/oc/bootstrap/docker/errors"
)
type runError struct {
error
stdOut string
stdErr string
config *container.Config
}
func newRunError(rc int, cause error, stdOut, stdErr string, config *container.Config) error {
return &runError{
error: errors.NewError("Docker run error rc=%d", rc).WithCause(cause),
stdOut: stdOut,
stdErr: stdErr,
config: config,
}
}
func (e *runError) Details() string {
out := &bytes.Buffer{}
fmt.Fprintf(out, "Image: %s\n", e.config.Image)
fmt.Fprintf(out, "Entrypoint: %v\n", e.config.Entrypoint)
fmt.Fprintf(out, "Command: %v\n", e.config.Cmd)
if len(e.stdOut) > 0 {
errors.PrintLog(out, "Output", e.stdOut)
}
if len(e.stdErr) > 0 {
errors.PrintLog(out, "Error Output", e.stdErr)
}
return out.String()
}