v.io/core/veyron/runtimes/google: convert to use verror2
This CL converts
v.io/core/veyron/runtimes/google/ipc/stream/vif/vif.go
v.io/core/veyron/runtimes/google/naming/namespace/namespace.go
to use verror2 instead of verror1.
In the first, a custom error is wrapped in a standard error code (Aborted)
because some other parts of the code (manager.go?) test for Aborted
as a special case. We may wish to fix this later.
In the second, a custom error code is used.
In addition, some unused routines are removed from verror1.
Tested:
cd release/go/src/v.io/core
v23 go test ./...
v23 test run vanadium-go-test
Change-Id: Icf2000dbe4f7f1ec18568b041e3996f7119d5760
diff --git a/runtimes/google/ipc/stream/vif/vif.go b/runtimes/google/ipc/stream/vif/vif.go
index 2a7c22c..21122db 100644
--- a/runtimes/google/ipc/stream/vif/vif.go
+++ b/runtimes/google/ipc/stream/vif/vif.go
@@ -27,11 +27,17 @@
vsync "v.io/core/veyron/runtimes/google/lib/sync"
"v.io/core/veyron/runtimes/google/lib/upcqueue"
"v.io/core/veyron2/naming"
- "v.io/core/veyron2/verror"
+ verror "v.io/core/veyron2/verror2"
"v.io/core/veyron2/vlog"
"v.io/core/veyron2/vtrace"
)
+const pkgPath = "v.io/core/veyron/runtimes/google/ipc/stream/vif"
+
+var (
+ errShuttingDown = verror.Register(pkgPath+".errShuttingDown", verror.NoRetry, "{1:}{2:} underlying network connection({3}) shutting down{:_}")
+)
+
// VIF implements a "virtual interface" over an underlying network connection
// (net.Conn). Just like multiple network connections can be established over a
// single physical interface, multiple Virtual Circuits (VCs) can be
@@ -744,8 +750,10 @@
}
vif.vcMap.Delete(vci)
vc.Close("underlying network connection shutting down")
- // Should a custom errorid be used?
- return nil, verror.Abortedf("underlying network connection(%v) shutting down", vif)
+ // We embed an error inside verror.Aborted because other layers
+ // check for the "Aborted" error as a special case. Perhaps
+ // eventually we'll get rid of the Aborted layer.
+ return nil, verror.Make(verror.Aborted, nil, verror.Make(errShuttingDown, nil, vif))
}
return vc, nil
}
diff --git a/runtimes/google/naming/namespace/namespace.go b/runtimes/google/naming/namespace/namespace.go
index c870b88..d1eccae 100644
--- a/runtimes/google/naming/namespace/namespace.go
+++ b/runtimes/google/naming/namespace/namespace.go
@@ -9,8 +9,7 @@
"v.io/core/veyron2/naming"
"v.io/core/veyron2/security"
- "v.io/core/veyron2/verror"
- "v.io/core/veyron2/verror2"
+ verror "v.io/core/veyron2/verror2"
"v.io/core/veyron2/vlog"
)
@@ -19,6 +18,12 @@
var serverPatternRegexp = regexp.MustCompile("^\\[([^\\]]+)\\](.*)")
+const pkgPath = "v.io/core/veyron/runtimes/google/naming/namespace"
+
+var (
+ errNotRootedName = verror.Register(pkgPath+".errNotRootedName", verror.NoRetry, "{1:}{2:} At least one root is not a rooted name{:_}")
+)
+
// namespace is an implementation of naming.Namespace.
type namespace struct {
sync.RWMutex
@@ -44,7 +49,7 @@
}
func badRoots(roots []string) error {
- return verror.BadArgf("At least one root is not a rooted name: %q", roots)
+ return verror.Make(errNotRootedName, nil, roots)
}
// Create a new namespace.
@@ -143,15 +148,15 @@
// notAnMT returns true if the error indicates this isn't a mounttable server.
func notAnMT(err error) bool {
- switch verror2.ErrorID(err) {
- case verror2.BadArg.ID:
+ switch verror.ErrorID(err) {
+ case verror.BadArg.ID:
// This should cover "ipc: wrong number of in-args".
return true
- case verror2.NoExist.ID:
+ case verror.NoExist.ID:
// This should cover "ipc: unknown method", "ipc: dispatcher not
// found", and dispatcher Lookup not found errors.
return true
- case verror2.BadProtocol.ID:
+ case verror.BadProtocol.ID:
// This covers "ipc: response decoding failed: EOF".
return true
}