handle watch errors everywhere
This commit is contained in:
@@ -21,6 +21,7 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||
)
|
||||
|
||||
// statusError is an error intended for consumption by a REST API server.
|
||||
@@ -38,6 +39,16 @@ func (e *statusError) Status() api.Status {
|
||||
return e.status
|
||||
}
|
||||
|
||||
// FromObject generates an statusError from an api.Status, if that is the type of obj; otherwise,
|
||||
// returns an error created by fmt.Errorf.
|
||||
func FromObject(obj runtime.Object) error {
|
||||
switch t := obj.(type) {
|
||||
case *api.Status:
|
||||
return &statusError{*t}
|
||||
}
|
||||
return fmt.Errorf("unexpected object: %v", obj)
|
||||
}
|
||||
|
||||
// NewNotFound returns a new error which indicates that the resource of the kind and the name was not found.
|
||||
func NewNotFound(kind, name string) error {
|
||||
return &statusError{api.Status{
|
||||
|
Reference in New Issue
Block a user