mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-04 02:30:45 +00:00
``` $ gvt delete github.com/opencontainers/runc/libcontainer/cgroups $ gvt delete github.com/opencontainers/runc/libcontainer/configs $ gvt delete github.com/opencontainers/runc/libcontainer/system $ gvt delete github.com/opencontainers/runc/libcontainer/user $ gvt delete github.com/opencontainers/runc/libcontainer/utils $ gvt fetch --tag v1.0.0-rc5 github.com/opencontainers/runc/libcontainer 2018/07/23 17:08:18 Fetching: github.com/opencontainers/runc/libcontainer 2018/07/23 17:08:24 · Fetching recursive dependency: github.com/opencontainers/runc/vendor/github.com/vishvananda/netlink 2018/07/23 17:08:24 · Fetching recursive dependency: github.com/opencontainers/runc/vendor/golang.org/x/sys/unix 2018/07/23 17:08:24 · Fetching recursive dependency: github.com/opencontainers/runc/vendor/github.com/cyphar/filepath-securejoin 2018/07/23 17:08:24 ·· Fetching recursive dependency: github.com/opencontainers/runc/vendor/github.com/pkg/errors 2018/07/23 17:08:24 · Fetching recursive dependency: github.com/opencontainers/runc/vendor/github.com/opencontainers/selinux/go-selinux/label 2018/07/23 17:08:25 ·· Fetching recursive dependency: github.com/opencontainers/runc/vendor/github.com/opencontainers/selinux/go-selinux 2018/07/23 17:08:25 · Fetching recursive dependency: github.com/opencontainers/runc/vendor/github.com/containerd/console 2018/07/23 17:08:25 ·· Fetching recursive dependency: github.com/opencontainers/runc/vendor/golang.org/x/sys/windows 2018/07/23 17:08:25 · Fetching recursive dependency: github.com/opencontainers/runc/vendor/github.com/sirupsen/logrus 2018/07/23 17:08:25 · Fetching recursive dependency: github.com/opencontainers/runc/vendor/github.com/godbus/dbus 2018/07/23 17:08:25 · Fetching recursive dependency: github.com/opencontainers/runc/vendor/github.com/mrunalp/fileutils 2018/07/23 17:08:25 · Fetching recursive dependency: github.com/opencontainers/runc/vendor/github.com/coreos/go-systemd/util 2018/07/23 17:08:25 ·· Fetching recursive dependency: github.com/opencontainers/runc/vendor/github.com/coreos/pkg/dlopen 2018/07/23 17:08:25 · Fetching recursive dependency: github.com/opencontainers/runc/vendor/github.com/golang/protobuf/proto 2018/07/23 17:08:25 · Fetching recursive dependency: github.com/opencontainers/runc/vendor/github.com/syndtr/gocapability/capability 2018/07/23 17:08:25 · Fetching recursive dependency: github.com/opencontainers/runc/vendor/github.com/coreos/go-systemd/dbus 2018/07/23 17:08:25 · Fetching recursive dependency: github.com/opencontainers/runc/vendor/github.com/opencontainers/runtime-spec/specs-go 2018/07/23 17:08:25 · Fetching recursive dependency: github.com/opencontainers/runc/vendor/github.com/seccomp/libseccomp-golang 2018/07/23 17:08:25 · Fetching recursive dependency: github.com/opencontainers/runc/vendor/github.com/docker/go-units ```
93 lines
2.0 KiB
Go
93 lines
2.0 KiB
Go
package libcontainer
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
"text/template"
|
|
"time"
|
|
|
|
"github.com/opencontainers/runc/libcontainer/stacktrace"
|
|
)
|
|
|
|
var errorTemplate = template.Must(template.New("error").Parse(`Timestamp: {{.Timestamp}}
|
|
Code: {{.ECode}}
|
|
{{if .Message }}
|
|
Message: {{.Message}}
|
|
{{end}}
|
|
Frames:{{range $i, $frame := .Stack.Frames}}
|
|
---
|
|
{{$i}}: {{$frame.Function}}
|
|
Package: {{$frame.Package}}
|
|
File: {{$frame.File}}@{{$frame.Line}}{{end}}
|
|
`))
|
|
|
|
func newGenericError(err error, c ErrorCode) Error {
|
|
if le, ok := err.(Error); ok {
|
|
return le
|
|
}
|
|
gerr := &genericError{
|
|
Timestamp: time.Now(),
|
|
Err: err,
|
|
ECode: c,
|
|
Stack: stacktrace.Capture(1),
|
|
}
|
|
if err != nil {
|
|
gerr.Message = err.Error()
|
|
}
|
|
return gerr
|
|
}
|
|
|
|
func newSystemError(err error) Error {
|
|
return createSystemError(err, "")
|
|
}
|
|
|
|
func newSystemErrorWithCausef(err error, cause string, v ...interface{}) Error {
|
|
return createSystemError(err, fmt.Sprintf(cause, v...))
|
|
}
|
|
|
|
func newSystemErrorWithCause(err error, cause string) Error {
|
|
return createSystemError(err, cause)
|
|
}
|
|
|
|
// createSystemError creates the specified error with the correct number of
|
|
// stack frames skipped. This is only to be called by the other functions for
|
|
// formatting the error.
|
|
func createSystemError(err error, cause string) Error {
|
|
gerr := &genericError{
|
|
Timestamp: time.Now(),
|
|
Err: err,
|
|
ECode: SystemError,
|
|
Cause: cause,
|
|
Stack: stacktrace.Capture(2),
|
|
}
|
|
if err != nil {
|
|
gerr.Message = err.Error()
|
|
}
|
|
return gerr
|
|
}
|
|
|
|
type genericError struct {
|
|
Timestamp time.Time
|
|
ECode ErrorCode
|
|
Err error `json:"-"`
|
|
Cause string
|
|
Message string
|
|
Stack stacktrace.Stacktrace
|
|
}
|
|
|
|
func (e *genericError) Error() string {
|
|
if e.Cause == "" {
|
|
return e.Message
|
|
}
|
|
frame := e.Stack.Frames[0]
|
|
return fmt.Sprintf("%s:%d: %s caused %q", frame.File, frame.Line, e.Cause, e.Message)
|
|
}
|
|
|
|
func (e *genericError) Code() ErrorCode {
|
|
return e.ECode
|
|
}
|
|
|
|
func (e *genericError) Detail(w io.Writer) error {
|
|
return errorTemplate.Execute(w, e)
|
|
}
|