veyron2/verror: Rename NotFound and NotAuthorized, introduce NoExistOrNoAccess.
Rename NotFound to NoExist and NotAuthorized to NoAccess.
Introduce a new error, NoExistOrNoAccess, that indicates that a principal may
not access an entity because it does not exist.
NoExist now indicates that a principal may not access an entity either
because the entity does not exist, or the principal is not authorized to
access the entity.
Change-Id: I74116a5fcc7c2486ae356070c63a8c2b7edcb4bd
diff --git a/runtimes/google/ipc/client.go b/runtimes/google/ipc/client.go
index 4a61b55..2dfecec 100644
--- a/runtimes/google/ipc/client.go
+++ b/runtimes/google/ipc/client.go
@@ -25,7 +25,7 @@
)
var (
- errNoServers = verror.NotFoundf("ipc: no servers")
+ errNoServers = verror.NoExistf("ipc: no servers")
errFlowClosed = verror.Abortedf("ipc: flow closed")
errRemainingStreamResults = verror.BadProtocolf("ipc: Finish called with remaining streaming results")
errNonRootedName = verror.BadArgf("ipc: cannot connect to a non-rooted name")
@@ -200,7 +200,7 @@
servers, err := c.ns.Resolve(ctx, name)
if err != nil {
- return nil, verror.NotFoundf("ipc: Resolve(%q) failed: %v", name, err)
+ return nil, verror.NoExistf("ipc: Resolve(%q) failed: %v", name, err)
}
// Try all servers, and if none of them are authorized for the call then return the error of the last server
// that was tried.
@@ -208,7 +208,7 @@
for _, server := range servers {
flow, suffix, err := c.connectFlow(server)
if err != nil {
- lastErr = verror.NotFoundf("ipc: couldn't connect to server %v: %v", server, err)
+ lastErr = verror.NoExistf("ipc: couldn't connect to server %v: %v", server, err)
vlog.VI(2).Infof("ipc: couldn't connect to server %v: %v", server, err)
continue // Try the next server.
}
@@ -224,7 +224,7 @@
// Validate caveats on the server's identity for the context associated with this call.
blessing, err := authorizeServer(flow.LocalID(), flow.RemoteID(), opts)
if err != nil {
- lastErr = verror.NotAuthorizedf("ipc: client unwilling to talk to server %q: %v", flow.RemoteID(), err)
+ lastErr = verror.NoAccessf("ipc: client unwilling to talk to server %q: %v", flow.RemoteID(), err)
flow.Close()
continue
}
@@ -482,7 +482,7 @@
vtrace.MergeResponse(fc.ctx, &fc.response.TraceResponse)
if fc.response.Error != nil {
- if verror.Is(fc.response.Error, verror.NotAuthorized) && fc.dischargeCache != nil {
+ if verror.Is(fc.response.Error, verror.NoAccess) && fc.dischargeCache != nil {
// In case the error was caused by a bad discharge, we do not want to get stuck
// with retrying again and again with this discharge. As there is no direct way
// to detect it, we conservatively flush all discharges we used from the cache.
diff --git a/runtimes/google/ipc/server.go b/runtimes/google/ipc/server.go
index ae507af..2859f63 100644
--- a/runtimes/google/ipc/server.go
+++ b/runtimes/google/ipc/server.go
@@ -34,7 +34,7 @@
)
func errNotAuthorized(err error) verror.E {
- return verror.NotAuthorizedf("ipc: not authorized(%v)", err)
+ return verror.NoAccessf("ipc: not authorized(%v)", err)
}
type server struct {
@@ -800,7 +800,7 @@
return invoker, auth, name, nil
}
}
- return nil, nil, "", verror.NotFoundf(fmt.Sprintf("ipc: dispatcher not found for %q", name))
+ return nil, nil, "", verror.NoExistf(fmt.Sprintf("ipc: dispatcher not found for %q", name))
}
func (fs *flowServer) authorize(auth security.Authorizer) error {
diff --git a/runtimes/google/naming/namespace/namespace.go b/runtimes/google/naming/namespace/namespace.go
index 1482f67..a3a3d2d 100644
--- a/runtimes/google/naming/namespace/namespace.go
+++ b/runtimes/google/naming/namespace/namespace.go
@@ -110,7 +110,7 @@
case verror.BadArg:
// This should cover "ipc: wrong number of in-args".
return true
- case verror.NotFound:
+ case verror.NoExist:
// This should cover "ipc: unknown method", "ipc: dispatcher not
// found", and "ipc: LeafDispatcher lookup on non-empty suffix".
return true
diff --git a/runtimes/google/testing/mocks/naming/namespace.go b/runtimes/google/testing/mocks/naming/namespace.go
index a587e64..68ae90a 100644
--- a/runtimes/google/testing/mocks/naming/namespace.go
+++ b/runtimes/google/testing/mocks/naming/namespace.go
@@ -70,7 +70,7 @@
return ret, nil
}
}
- return nil, verror.NotFoundf("Resolve name %q not found in %v", name, ns.mounts)
+ return nil, verror.NoExistf("Resolve name %q not found in %v", name, ns.mounts)
}
func (ns *namespace) ResolveToMountTable(ctx context.T, name string) ([]string, error) {