k8s/io/kubernetes/pkg/api/errors.NewNotFound 示例代码

2022-03-03

以下示例是关于golang中包含errors.NewNotFound用法的示例代码,想了解errors.NewNotFound的具体用法?errors.NewNotFound怎么用?errors.NewNotFound使用的例子?那么可以参考以下10个相关示例代码来学习它的具体使用方法。

示例1:
rest.go开发语言: Go项目名称: kubernetes代码行数: 81
44func (*REST) List(ctx api.Context, label, field labels.Selector) (runtime.Object, error) {
45	return nil, errors.NewNotFound("binding", "list")
46}
49func (*REST) Get(ctx api.Context, id string) (runtime.Object, error) {
50	return nil, errors.NewNotFound("binding", id)
51}
54func (*REST) Delete(ctx api.Context, id string) (<-chan runtime.Object, error) {
55	return nil, errors.NewNotFound("binding", id)
56}
示例2:
etcd.go开发语言: Go项目名称: kubernetes代码行数: 67
28	case tools.IsEtcdNotFound(err):
29		return errors.NewNotFound(kind, name)
30	default:
61	case tools.IsEtcdNotFound(err):
62		return errors.NewNotFound(kind, name)
63	default:
示例3:
rest_test.go开发语言: Go项目名称: kubernetes代码行数: 99
48	registry := ®istrytest.ServiceRegistry{
49		Err: errors.NewNotFound("service", "foo"),
50	}
54	_, err := storage.Get(ctx, "foo")
55	if !errors.IsNotFound(err) || !reflect.DeepEqual(err, errors.NewNotFound("service", "foo")) {
56		t.Errorf("expected NotFound error, got %#v", err)
示例4:
rest_test.go开发语言: Go项目名称: kubernetes代码行数: 99
48	registry := ®istrytest.ServiceRegistry{
49		Err: errors.NewNotFound("service", "foo"),
50	}
54	_, err := storage.Get(ctx, "foo")
55	if !errors.IsNotFound(err) || !reflect.DeepEqual(err, errors.NewNotFound("service", "foo")) {
56		t.Errorf("expected NotFound error, got %#v", err)
示例5:
conditions.go开发语言: Go项目名称: abhgupta代码行数: 282
158	case watch.Deleted:
159		return false, errors.NewNotFound(schema.GroupResource{Resource: "pods"}, "")
160	}
177	case watch.Deleted:
178		return false, errors.NewNotFound(schema.GroupResource{Resource: "pods"}, "")
179	}
195	case watch.Deleted:
196		return false, errors.NewNotFound(schema.GroupResource{Resource: "pods"}, "")
197	}
214	case watch.Deleted:
215		return false, errors.NewNotFound(schema.GroupResource{Resource: "pods"}, "")
216	}
234		case watch.Deleted:
235			return false, errors.NewNotFound(schema.GroupResource{Resource: "pods"}, "")
236		}
示例6:
storage.go开发语言: Go项目名称: abhgupta代码行数: 116
29	case storage.IsNotFound(err):
30		return errors.NewNotFound(qualifiedResource, "")
31	case storage.IsUnreachable(err):
44	case storage.IsNotFound(err):
45		return errors.NewNotFound(qualifiedResource, name)
46	case storage.IsUnreachable(err):
78	case storage.IsNotFound(err):
79		return errors.NewNotFound(qualifiedResource, name)
80	case storage.IsInternalError(err):
91	case storage.IsNotFound(err):
92		return errors.NewNotFound(qualifiedResource, name)
93	case storage.IsUnreachable(err):
示例7:
etcd.go开发语言: Go项目名称: amygdala代码行数: 90
29	case storage.IsNotFound(err):
30		return errors.NewNotFound(qualifiedResource, "")
31	case storage.IsUnreachable(err):
42	case storage.IsNotFound(err):
43		return errors.NewNotFound(qualifiedResource, name)
44	case storage.IsUnreachable(err):
72	case storage.IsNotFound(err):
73		return errors.NewNotFound(qualifiedResource, name)
74	default:
83	case storage.IsNotFound(err):
84		return errors.NewNotFound(qualifiedResource, name)
85	case storage.IsUnreachable(err):
示例8:
unjoin_test.go开发语言: Go项目名称: ddysher代码行数: 304
191				if got != name {
192					return nil, errors.NewNotFound(federationapi.Resource("clusters"), got)
193				}
249					if got != clusterName {
250						return nil, errors.NewNotFound(api.Resource("secrets"), got)
251					}
258					if got != clusterName {
259						return nil, errors.NewNotFound(api.Resource("secrets"), got)
260					}
268				if got != want {
269					return nil, errors.NewNotFound(api.Resource("serviceaccounts"), got)
270				}
279				if got != want {
280					return nil, errors.NewNotFound(api.Resource("clusterrolebindings"), got)
281				}
示例9:
conditions.go开发语言: Go项目名称: ddysher代码行数: 165
41	case watch.Deleted:
42		return false, errors.NewNotFound(schema.GroupResource{Resource: "pods"}, "")
43	}
60	case watch.Deleted:
61		return false, errors.NewNotFound(schema.GroupResource{Resource: "pods"}, "")
62	}
78	case watch.Deleted:
79		return false, errors.NewNotFound(schema.GroupResource{Resource: "pods"}, "")
80	}
97	case watch.Deleted:
98		return false, errors.NewNotFound(schema.GroupResource{Resource: "pods"}, "")
99	}
117		case watch.Deleted:
118			return false, errors.NewNotFound(schema.GroupResource{Resource: "pods"}, "")
119		}
示例10:
conditions.go开发语言: Go项目名称: ddysher代码行数: 282
158	case watch.Deleted:
159		return false, errors.NewNotFound(schema.GroupResource{Resource: "pods"}, "")
160	}
177	case watch.Deleted:
178		return false, errors.NewNotFound(schema.GroupResource{Resource: "pods"}, "")
179	}
195	case watch.Deleted:
196		return false, errors.NewNotFound(schema.GroupResource{Resource: "pods"}, "")
197	}
214	case watch.Deleted:
215		return false, errors.NewNotFound(schema.GroupResource{Resource: "pods"}, "")
216	}
234		case watch.Deleted:
235			return false, errors.NewNotFound(schema.GroupResource{Resource: "pods"}, "")
236		}

本文地址:https://www.itbaoku.cn/snippets/415707.html