x/ref: Remove verror.Is and verror.Equal
It's simpler to just use verror.ErrorID instead
MultiPart: 2/2
Change-Id: I12886abe7e7d6345186022b9127d45c6fff54ec6
diff --git a/cmd/mgmt/device/impl/acl_impl.go b/cmd/mgmt/device/impl/acl_impl.go
index 7012e0f..8cd5dee 100644
--- a/cmd/mgmt/device/impl/acl_impl.go
+++ b/cmd/mgmt/device/impl/acl_impl.go
@@ -125,7 +125,7 @@
}
}
switch err := device.ApplicationClient(vanaName).SetPermissions(gctx, objAccessList, etag); {
- case err != nil && !verror.Is(err, verror.ErrBadEtag.ID):
+ case err != nil && verror.ErrorID(err) != verror.ErrBadEtag.ID:
return fmt.Errorf("SetPermissions(%s) failed: %v", vanaName, err)
case err == nil:
return nil
diff --git a/cmd/mgmt/device/impl/impl_test.go b/cmd/mgmt/device/impl/impl_test.go
index 25de421..de48dae 100644
--- a/cmd/mgmt/device/impl/impl_test.go
+++ b/cmd/mgmt/device/impl/impl_test.go
@@ -331,7 +331,7 @@
t.Fatalf("Failed to marshal principal public key: %v", err)
}
}
- if err := cmd.Execute([]string{"claim", deviceName, "grant", pairingToken, base64.URLEncoding.EncodeToString(deviceKeyWrong)}); !verror.Is(err, verror.ErrNotTrusted.ID) {
+ if err := cmd.Execute([]string{"claim", deviceName, "grant", pairingToken, base64.URLEncoding.EncodeToString(deviceKeyWrong)}); verror.ErrorID(err) != verror.ErrNotTrusted.ID {
t.Fatalf("wrongly failed to receive correct error on claim with incorrect device key:%v id:%v", err, verror.ErrorID(err))
}
stdout.Reset()
diff --git a/cmd/mgmt/device/impl/publish.go b/cmd/mgmt/device/impl/publish.go
index dbafdba..2a009a9 100644
--- a/cmd/mgmt/device/impl/publish.go
+++ b/cmd/mgmt/device/impl/publish.go
@@ -126,7 +126,7 @@
// the first match. But presumably that's ok, since we're going to set
// the envelopes for all the profiles to the same envelope anyway below.
envelope, err := appClient.Match(gctx, profiles)
- if verror.Is(err, appdimpl.ErrNotFound.ID) {
+ if verror.ErrorID(err) == appdimpl.ErrNotFound.ID {
// There was nothing published yet, create a new envelope.
envelope = application.Envelope{Title: binaryName}
} else if err != nil {
diff --git a/cmd/mgmt/device/impl/updateall.go b/cmd/mgmt/device/impl/updateall.go
index a833157..beb83cf 100644
--- a/cmd/mgmt/device/impl/updateall.go
+++ b/cmd/mgmt/device/impl/updateall.go
@@ -106,7 +106,7 @@
}
}
}()
- case verror.Is(err, deviceimpl.ErrInvalidOperation.ID):
+ case verror.ErrorID(err) == deviceimpl.ErrInvalidOperation.ID:
// App was likely not running.
//
// TODO(caprita): change returned error to distinguish no-op
@@ -118,7 +118,7 @@
switch err := device.ApplicationClient(von).Update(gctx); {
case err == nil:
return nil
- case verror.Is(err, deviceimpl.ErrUpdateNoOp.ID):
+ case verror.ErrorID(err) == deviceimpl.ErrUpdateNoOp.ID:
// TODO(caprita): Ideally, we wouldn't even attempt a suspend /
// resume if there's no newer version of the application.
fmt.Fprintf(cmd.Stdout(), "Instance %q already up to date.\n", von)
@@ -142,7 +142,7 @@
switch err := device.ApplicationClient(von).Update(gctx); {
case err == nil:
fmt.Fprintf(cmd.Stdout(), "Successfully updated version for installation %q.\n", von)
- case verror.Is(err, deviceimpl.ErrUpdateNoOp.ID):
+ case verror.ErrorID(err) == deviceimpl.ErrUpdateNoOp.ID:
fmt.Fprintf(cmd.Stdout(), "Installation %q already up to date.\n", von)
// NOTE: we still proceed to update the instances in this case,
// since it's possible that some instances are still running
diff --git a/lib/exec/config_test.go b/lib/exec/config_test.go
index 59b7c8c..6bad180 100644
--- a/lib/exec/config_test.go
+++ b/lib/exec/config_test.go
@@ -20,7 +20,7 @@
}
func checkAbsent(t *testing.T, c Config, k string) {
- if v, err := c.Get(k); !verror.Is(err, verror.ErrNoExist.ID) {
+ if v, err := c.Get(k); verror.ErrorID(err) != verror.ErrNoExist.ID {
t.Errorf("Expected (\"\", %v) for key %q, got (%q, %v) instead", verror.ErrNoExist, k, v, err)
}
}
diff --git a/profiles/internal/naming/namespace/all_test.go b/profiles/internal/naming/namespace/all_test.go
index d4d37f7..7ff78dc 100644
--- a/profiles/internal/naming/namespace/all_test.go
+++ b/profiles/internal/naming/namespace/all_test.go
@@ -327,7 +327,7 @@
// /mt2 is not an endpoint. Thus, the example below will fail.
mt3Server := mts[mt3MP].name
mt2a := "/mt2/a"
- if err := ns.Mount(c, mt2a, mt3Server, ttl); verror.Is(err, naming.ErrNoSuchName.ID) {
+ if err := ns.Mount(c, mt2a, mt3Server, ttl); verror.ErrorID(err) == naming.ErrNoSuchName.ID {
boom(t, "Successfully mounted %s - expected an err %v, not %v", mt2a, naming.ErrNoSuchName, err)
}
@@ -570,7 +570,7 @@
for i := 0; i < 40; i++ {
cycle += "/c3/c4"
}
- if _, err := ns.Resolve(c, "c1/"+cycle); !verror.Is(err, naming.ErrResolutionDepthExceeded.ID) {
+ if _, err := ns.Resolve(c, "c1/"+cycle); verror.ErrorID(err) != naming.ErrResolutionDepthExceeded.ID {
boom(t, "Failed to detect cycle")
}
@@ -664,7 +664,7 @@
for _, root := range []string{hproot, eproot} {
name := naming.JoinAddressName(root, "mt")
// Rooted name resolutions should fail authorization because of the "otherrot"
- if e, err := resolve(name); !verror.Is(err, verror.ErrNotTrusted.ID) {
+ if e, err := resolve(name); verror.ErrorID(err) != verror.ErrNotTrusted.ID {
t.Errorf("resolve(%q) returned (%v, errorid=%v %v), wanted errorid=%v", name, e, verror.ErrorID(err), err, verror.ErrNotTrusted.ID)
}
// But not fail if the skip-authorization option is provided
@@ -673,7 +673,7 @@
}
// The namespace root from the context should be authorized as well.
ctx, ns, _ := v23.SetNewNamespace(clientCtx, naming.JoinAddressName(root, ""))
- if e, err := ns.Resolve(ctx, "mt/server"); !verror.Is(err, verror.ErrNotTrusted.ID) {
+ if e, err := ns.Resolve(ctx, "mt/server"); verror.ErrorID(err) != verror.ErrNotTrusted.ID {
t.Errorf("resolve with root=%q returned (%v, errorid=%v %v), wanted errorid=%v", root, e, verror.ErrorID(err), err, verror.ErrNotTrusted.ID)
}
if _, err := ns.Resolve(ctx, "mt/server", options.SkipServerEndpointAuthorization{}); err != nil {
@@ -693,7 +693,7 @@
if e, err := resolve("mt/server", options.SkipServerEndpointAuthorization{}); err != nil {
t.Errorf("Resolve should succeed when skipping server authorization. Got (%v, %v)", e, err)
- } else if e, err := resolve("mt/server"); !verror.Is(err, verror.ErrNotTrusted.ID) {
+ } else if e, err := resolve("mt/server"); verror.ErrorID(err) != verror.ErrNotTrusted.ID {
t.Errorf("Resolve should have failed with %q because an attacker has taken over the intermediate mounttable. Got (%+v, errorid=%q:%v)", verror.ErrNotTrusted.ID, e, verror.ErrorID(err), err)
}
}
diff --git a/profiles/internal/naming/namespace/resolve.go b/profiles/internal/naming/namespace/resolve.go
index 59f5f2a..07e22d2 100644
--- a/profiles/internal/naming/namespace/resolve.go
+++ b/profiles/internal/naming/namespace/resolve.go
@@ -40,7 +40,7 @@
entry := new(naming.MountEntry)
if err := call.Finish(entry); err != nil {
// If any replica says the name doesn't exist, return that fact.
- if verror.Is(err, naming.ErrNoSuchName.ID) || verror.Is(err, naming.ErrNoSuchNameRoot.ID) {
+ if verror.ErrorID(err) == naming.ErrNoSuchName.ID || verror.ErrorID(err) == naming.ErrNoSuchNameRoot.ID {
return nil, err
}
// Keep track of the final error and continue with next server.
@@ -97,7 +97,7 @@
vlog.VI(1).Infof("Resolve(%s) -> %v", name, curr)
return curr, nil
}
- if verror.Is(err, naming.ErrNoSuchNameRoot.ID) {
+ if verror.ErrorID(err) == naming.ErrNoSuchNameRoot.ID {
err = verror.New(naming.ErrNoSuchName, ctx, name)
}
vlog.VI(1).Infof("Resolve(%s) -> (%s: %v)", err, name, curr)
@@ -132,11 +132,11 @@
return last, nil
}
if e, err = ns.resolveAgainstMountTable(ctx, client, e, callOpts...); err != nil {
- if verror.Is(err, naming.ErrNoSuchNameRoot.ID) {
+ if verror.ErrorID(err) == naming.ErrNoSuchNameRoot.ID {
vlog.VI(1).Infof("ResolveToMountTable(%s) -> %v (NoSuchRoot: %v)", name, last, curr)
return last, nil
}
- if verror.Is(err, naming.ErrNoSuchName.ID) {
+ if verror.ErrorID(err) == naming.ErrNoSuchName.ID {
vlog.VI(1).Infof("ResolveToMountTable(%s) -> %v (NoSuchName: %v)", name, curr, curr)
return curr, nil
}
diff --git a/profiles/internal/rpc/client.go b/profiles/internal/rpc/client.go
index 194d12a..3aab4f9 100644
--- a/profiles/internal/rpc/client.go
+++ b/profiles/internal/rpc/client.go
@@ -389,7 +389,7 @@
// We always return NoServers as the error so that the caller knows
// that's ok to retry the operation since the name may be registered
// in the near future.
- if verror.Is(err, naming.ErrNoSuchName.ID) {
+ if verror.ErrorID(err) == naming.ErrNoSuchName.ID {
return nil, verror.RetryRefetch, verror.New(verror.ErrNoServers, ctx, name)
}
return nil, verror.NoRetry, verror.New(verror.ErrNoServers, ctx, name, err)
@@ -467,7 +467,7 @@
case <-timeoutChan:
vlog.VI(2).Infof("rpc: timeout on connection to server %v ", name)
_, _, err := c.failedTryCall(ctx, name, method, responses, ch)
- if !verror.Is(err, verror.ErrTimeout.ID) {
+ if verror.ErrorID(err) != verror.ErrTimeout.ID {
return nil, verror.NoRetry, verror.New(verror.ErrTimeout, ctx, err)
}
return nil, verror.NoRetry, err
@@ -578,7 +578,7 @@
for _, r := range responses {
if r != nil && r.err != nil {
switch {
- case verror.Is(r.err, verror.ErrNotTrusted.ID) || verror.Is(r.err, errAuthError.ID):
+ case verror.ErrorID(r.err) == verror.ErrNotTrusted.ID || verror.ErrorID(r.err) == errAuthError.ID:
untrusted = append(untrusted, "("+r.err.Error()+") ")
default:
noconn = append(noconn, "("+r.err.Error()+") ")
@@ -715,7 +715,7 @@
return verror.New(verror.ErrInternal, fc.ctx, err)
}
switch {
- case verror.Is(err, verror.ErrBadProtocol.ID):
+ case verror.ErrorID(err) == verror.ErrBadProtocol.ID:
switch fc.ctx.Err() {
case context.DeadlineExceeded:
// TODO(cnicolaou,m3b): reintroduce 'append' when the new verror API is done.
@@ -726,7 +726,7 @@
//return verror.Append(verror.New(verror.ErrCanceled, fc.ctx), verr)
return verror.New(verror.ErrCanceled, fc.ctx, err.Error())
}
- case verror.Is(err, verror.ErrTimeout.ID):
+ case verror.ErrorID(err) == verror.ErrTimeout.ID:
// Canceled trumps timeout.
if fc.ctx.Err() == context.Canceled {
// TODO(cnicolaou,m3b): reintroduce 'append' when the new verror API is done.
@@ -917,7 +917,7 @@
if fc.response.Error != nil {
// TODO(cnicolaou): remove verror.ErrNoAccess with verror version
// when rpc.Server is converted.
- if verror.Is(fc.response.Error, verror.ErrNoAccess.ID) && fc.dc != nil {
+ if verror.ErrorID(fc.response.Error) == verror.ErrNoAccess.ID && fc.dc != 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/profiles/internal/rpc/full_test.go b/profiles/internal/rpc/full_test.go
index 05314cb..5d555d3 100644
--- a/profiles/internal/rpc/full_test.go
+++ b/profiles/internal/rpc/full_test.go
@@ -307,7 +307,7 @@
// Check that we can no longer serve after Stop.
err := server.AddName("name doesn't matter")
- if err == nil || !verror.Is(err, verror.ErrBadState.ID) {
+ if err == nil || verror.ErrorID(err) != verror.ErrBadState.ID {
t.Errorf("either no error, or a wrong error was returned: %v", err)
}
vlog.VI(1).Info("server.Stop DONE")
@@ -375,7 +375,7 @@
if err == nil && id.ID == "" {
return true
}
- return verror.Is(err, id.ID)
+ return verror.ErrorID(err) == id.ID
}
func runServer(t *testing.T, ctx *context.T, ns ns.Namespace, principal security.Principal, name string, obj interface{}, opts ...rpc.ServerOpt) stream.Manager {
@@ -642,7 +642,7 @@
}
defer client.Close()
ctx, _ = v23.SetPrincipal(ctx, pclient)
- if _, err := client.StartCall(ctx, "mountpoint/server", "Closure", nil); !verror.Is(err, verror.ErrNotTrusted.ID) {
+ if _, err := client.StartCall(ctx, "mountpoint/server", "Closure", nil); verror.ErrorID(err) != verror.ErrNotTrusted.ID {
t.Errorf("Got error %v (errorid=%v), want errorid=%v", err, verror.ErrorID(err), verror.ErrNotTrusted.ID)
}
// But the RPC should succeed if the client explicitly
@@ -769,7 +769,7 @@
err = call.Finish(results...)
if got, want := err, test.finishErr; (got == nil) != (want == nil) {
t.Errorf(`%s call.Finish got error "%v", want "%v'`, name(test), got, want)
- } else if want != nil && !verror.Is(got, verror.ErrorID(want)) {
+ } else if want != nil && verror.ErrorID(got) != verror.ErrorID(want) {
t.Errorf(`%s call.Finish got error "%v", want "%v"`, name(test), got, want)
}
checkResultPtrs(t, name(test), results, test.results)
@@ -1137,7 +1137,7 @@
t.Errorf(`%s call.Finish got error: "%v", wanted the RPC to succeed`, name, err)
} else if err == nil && !test.authorized {
t.Errorf("%s call.Finish succeeded, expected authorization failure", name)
- } else if !test.authorized && !verror.Is(err, verror.ErrNoAccess.ID) {
+ } else if !test.authorized && verror.ErrorID(err) != verror.ErrNoAccess.ID {
t.Errorf("%s. call.Finish returned error %v(%v), wanted %v", name, verror.ErrorID(verror.Convert(verror.ErrNoAccess, nil, err)), err, verror.ErrNoAccess)
}
}
@@ -1506,7 +1506,7 @@
ctx, _ = v23.SetPrincipal(ctx, pclient)
_, err := b.client.StartCall(ctx, "incompatible/suffix", "Echo", []interface{}{"foo"}, options.NoRetry{})
- if !verror.Is(err, verror.ErrNoServers.ID) {
+ if verror.ErrorID(err) != verror.ErrNoServers.ID {
t.Errorf("Expected error %s, found: %v", verror.ErrNoServers, err)
}
@@ -1654,7 +1654,7 @@
if call != nil {
t.Errorf("Expected nil interface got: %#v", call)
}
- if !verror.Is(err, verror.ErrBadArg.ID) {
+ if verror.ErrorID(err) != verror.ErrBadArg.ID {
t.Errorf("Expected an BadArg error, got: %s", err.Error())
}
}
@@ -1956,7 +1956,7 @@
t.Errorf("Expected call to succeed but got %v", err)
}
// ...but fail if they differ.
- if _, err = client.StartCall(ctx, mountName, "Closure", nil, options.SkipServerEndpointAuthorization{}, options.ServerPublicKey{pother.PublicKey()}); !verror.Is(err, verror.ErrNotTrusted.ID) {
+ if _, err = client.StartCall(ctx, mountName, "Closure", nil, options.SkipServerEndpointAuthorization{}, options.ServerPublicKey{pother.PublicKey()}); verror.ErrorID(err) != verror.ErrNotTrusted.ID {
t.Errorf("got %v, want %v", verror.ErrorID(err), verror.ErrNotTrusted.ID)
}
}
diff --git a/profiles/internal/rpc/server_test.go b/profiles/internal/rpc/server_test.go
index 403ce73..ce935c9 100644
--- a/profiles/internal/rpc/server_test.go
+++ b/profiles/internal/rpc/server_test.go
@@ -102,11 +102,11 @@
}
defer server.Stop()
_, err = server.Listen(rpc.ListenSpec{})
- if !verror.Is(err, verror.ErrBadArg.ID) {
+ if verror.ErrorID(err) != verror.ErrBadArg.ID {
t.Fatalf("expected a BadArg error: got %v", err)
}
_, err = server.Listen(rpc.ListenSpec{Addrs: rpc.ListenAddrs{{"tcp", "*:0"}}})
- if !verror.Is(err, verror.ErrBadArg.ID) {
+ if verror.ErrorID(err) != verror.ErrBadArg.ID {
t.Fatalf("expected a BadArg error: got %v", err)
}
_, err = server.Listen(rpc.ListenSpec{
@@ -114,7 +114,7 @@
{"tcp", "*:0"},
{"tcp", "127.0.0.1:0"},
}})
- if verror.Is(err, verror.ErrBadArg.ID) {
+ if verror.ErrorID(err) == verror.ErrBadArg.ID {
t.Fatalf("expected a BadArg error: got %v", err)
}
status := server.Status()
@@ -122,7 +122,7 @@
t.Fatalf("got %s, want %s", got, want)
}
_, err = server.Listen(rpc.ListenSpec{Addrs: rpc.ListenAddrs{{"tcp", "*:0"}}})
- if !verror.Is(err, verror.ErrBadArg.ID) {
+ if verror.ErrorID(err) != verror.ErrBadArg.ID {
t.Fatalf("expected a BadArg error: got %v", err)
}
status = server.Status()
@@ -237,7 +237,7 @@
defer shutdown()
expectBadState := func(err error) {
- if !verror.Is(err, verror.ErrBadState.ID) {
+ if verror.ErrorID(err) != verror.ErrBadState.ID {
t.Fatalf("%s: unexpected error: %v", loc(1), err)
}
}
diff --git a/profiles/internal/rpc/test/client_test.go b/profiles/internal/rpc/test/client_test.go
index 4c831f4..fafec63 100644
--- a/profiles/internal/rpc/test/client_test.go
+++ b/profiles/internal/rpc/test/client_test.go
@@ -254,7 +254,7 @@
name := naming.JoinAddressName(naming.FormatEndpoint("tcp", "203.0.113.10:443"), "")
client := v23.GetClient(ctx)
_, err := client.StartCall(ctx, name, "echo", []interface{}{"args don't matter"})
- if !verror.Is(err, verror.ErrTimeout.ID) {
+ if verror.ErrorID(err) != verror.ErrTimeout.ID {
t.Fatalf("wrong error: %s", err)
}
}
@@ -296,7 +296,7 @@
func testForVerror(t *testing.T, err error, verr verror.IDAction) {
_, file, line, _ := runtime.Caller(1)
loc := fmt.Sprintf("%s:%d", filepath.Base(file), line)
- if !verror.Is(err, verr.ID) {
+ if verror.ErrorID(err) != verr.ID {
if _, ok := err.(verror.E); !ok {
t.Fatalf("%s: err %v not a verror", loc, err)
}
@@ -469,7 +469,7 @@
ctx, _ = context.WithTimeout(ctx, 300*time.Millisecond)
call, err := v23.GetClient(ctx).StartCall(ctx, name, "Source", []interface{}{want})
if err != nil {
- if !verror.Is(err, verror.ErrTimeout.ID) {
+ if verror.ErrorID(err) != verror.ErrTimeout.ID {
t.Fatalf("verror should be a timeout not %s: stack %s",
err, verror.Stack(err))
}
diff --git a/profiles/internal/rpc/test/proxy_test.go b/profiles/internal/rpc/test/proxy_test.go
index 3a8c154..fb89398 100644
--- a/profiles/internal/rpc/test/proxy_test.go
+++ b/profiles/internal/rpc/test/proxy_test.go
@@ -350,7 +350,7 @@
verifyMountMissing(t, ctx, ns, name)
status = server.Status()
- if len(status.Proxies) != 1 || status.Proxies[0].Proxy != spec.Proxy || !verror.Is(status.Proxies[0].Error, verror.ErrNoServers.ID) {
+ if len(status.Proxies) != 1 || status.Proxies[0].Proxy != spec.Proxy || verror.ErrorID(status.Proxies[0].Error) != verror.ErrNoServers.ID {
t.Fatalf("proxy status is incorrect: %v", status.Proxies)
}
diff --git a/profiles/internal/rpc/testutil_test.go b/profiles/internal/rpc/testutil_test.go
index bb43fdd..b48f6c6 100644
--- a/profiles/internal/rpc/testutil_test.go
+++ b/profiles/internal/rpc/testutil_test.go
@@ -48,7 +48,7 @@
if !ok {
t.Errorf("%s result %d got type %T, want %T", name, ix, g, w)
}
- if !verror.Is(g, w.ID) {
+ if verror.ErrorID(g) != w.ID {
t.Errorf("%s result %d got %v, want %v", name, ix, g, w)
}
default:
diff --git a/profiles/internal/rt/ipc_test.go b/profiles/internal/rt/ipc_test.go
index e7e05e3..d100b76 100644
--- a/profiles/internal/rt/ipc_test.go
+++ b/profiles/internal/rt/ipc_test.go
@@ -342,7 +342,7 @@
return nil
}
- if err := makeCall(); !verror.Is(err, verror.ErrNotTrusted.ID) {
+ if err := makeCall(); verror.ErrorID(err) != verror.ErrNotTrusted.ID {
t.Fatalf("got error %v, expected %v", err, verror.ErrNotTrusted.ID)
}
ds.mu.Lock()
@@ -368,7 +368,7 @@
if err := pserver.BlessingStore().SetDefault(rootServerInvalidTPCaveat); err != nil {
t.Fatal(err)
}
- if call, err := client.StartCall(clientCtx, serverName, "EchoBlessings", nil); verror.Is(err, verror.ErrNoAccess.ID) {
+ if call, err := client.StartCall(clientCtx, serverName, "EchoBlessings", nil); verror.ErrorID(err) == verror.ErrNoAccess.ID {
remoteBlessings, _ := call.RemoteBlessings()
t.Errorf("client.StartCall passed unexpectedly with remote end authenticated as: %v", remoteBlessings)
}
diff --git a/security/blessingroots_test.go b/security/blessingroots_test.go
index 412a0f3..e7ff446 100644
--- a/security/blessingroots_test.go
+++ b/security/blessingroots_test.go
@@ -73,7 +73,7 @@
}
}
for _, b := range d.notRecognized {
- if err, want := br.Recognized(d.root, b), security.ErrUnrecognizedRoot.ID; !verror.Is(err, want) {
+ if err, want := br.Recognized(d.root, b), security.ErrUnrecognizedRoot.ID; verror.ErrorID(err) != want {
return fmt.Errorf("Recognized(%v, %q): Got %v(errorid=%v), want errorid=%v", d.root, b, err, verror.ErrorID(err), want)
}
}
diff --git a/services/mgmt/application/impl/acl_test.go b/services/mgmt/application/impl/acl_test.go
index baa3506..bdcc0b8 100644
--- a/services/mgmt/application/impl/acl_test.go
+++ b/services/mgmt/application/impl/acl_test.go
@@ -112,7 +112,7 @@
}
// Envelope putting as other should fail.
- if err := v1stub.Put(otherCtx, []string{"base"}, envelopeV1); !verror.Is(err, verror.ErrNoAccess.ID) {
+ if err := v1stub.Put(otherCtx, []string{"base"}, envelopeV1); verror.ErrorID(err) != verror.ErrNoAccess.ID {
t.Fatalf("Put() returned errorid=%v wanted errorid=%v [%v]", verror.ErrorID(err), verror.ErrNoAccess.ID, err)
}
@@ -122,7 +122,7 @@
}
acl, etag, err := repostub.GetPermissions(ctx)
- if !verror.Is(err, impl.ErrNotFound.ID) {
+ if verror.ErrorID(err) != impl.ErrNotFound.ID {
t.Fatalf("GetPermissions should have failed with ErrNotFound but was: %v", err)
}
if got, want := etag, ""; got != want {
@@ -251,7 +251,7 @@
for _, path := range []string{"repo/search", "repo/search/v1", "repo/search/v2"} {
stub := repository.ApplicationClient(path)
acl, etag, err := stub.GetPermissions(ctx)
- if !verror.Is(err, impl.ErrNotFound.ID) {
+ if verror.ErrorID(err) != impl.ErrNotFound.ID {
t.Fatalf("GetPermissions should have failed with ErrNotFound but was: %v", err)
}
if got, want := etag, ""; got != want {
diff --git a/services/mgmt/application/impl/dispatcher.go b/services/mgmt/application/impl/dispatcher.go
index 89c9d91..7f04de0 100644
--- a/services/mgmt/application/impl/dispatcher.go
+++ b/services/mgmt/application/impl/dispatcher.go
@@ -52,7 +52,7 @@
func (store *applicationAccessListStore) TAMForPath(path string) (access.Permissions, bool, error) {
tam, _, err := getAccessList((*fs.Memstore)(store), path)
- if verror.Is(err, ErrNotFound.ID) {
+ if verror.ErrorID(err) == ErrNotFound.ID {
return nil, true, nil
}
if err != nil {
diff --git a/services/mgmt/application/impl/impl_test.go b/services/mgmt/application/impl/impl_test.go
index e6da1ba..247acee 100644
--- a/services/mgmt/application/impl/impl_test.go
+++ b/services/mgmt/application/impl/impl_test.go
@@ -97,7 +97,7 @@
if err := stubV2.Put(ctx, []string{"base"}, envelopeV2); err != nil {
t.Fatalf("Put() failed: %v", err)
}
- if err := stub.Put(ctx, []string{"base", "media"}, envelopeV1); err == nil || !verror.Is(err, impl.ErrInvalidSuffix.ID) {
+ if err := stub.Put(ctx, []string{"base", "media"}, envelopeV1); err == nil || verror.ErrorID(err) != impl.ErrInvalidSuffix.ID {
t.Fatalf("Unexpected error: expected %v, got %v", impl.ErrInvalidSuffix, err)
}
@@ -116,13 +116,13 @@
if !reflect.DeepEqual(envelopeV1, output) {
t.Fatalf("Unexpected output: expected %v, got %v", envelopeV1, output)
}
- if _, err := stubV2.Match(ctx, []string{"media"}); err == nil || !verror.Is(err, impl.ErrNotFound.ID) {
+ if _, err := stubV2.Match(ctx, []string{"media"}); err == nil || verror.ErrorID(err) != impl.ErrNotFound.ID {
t.Fatalf("Unexpected error: expected %v, got %v", impl.ErrNotFound, err)
}
- if _, err := stubV2.Match(ctx, []string{}); err == nil || !verror.Is(err, impl.ErrNotFound.ID) {
+ if _, err := stubV2.Match(ctx, []string{}); err == nil || verror.ErrorID(err) != impl.ErrNotFound.ID {
t.Fatalf("Unexpected error: expected %v, got %v", impl.ErrNotFound, err)
}
- if _, err := stub.Match(ctx, []string{"media"}); err == nil || !verror.Is(err, impl.ErrInvalidSuffix.ID) {
+ if _, err := stub.Match(ctx, []string{"media"}); err == nil || verror.ErrorID(err) != impl.ErrInvalidSuffix.ID {
t.Fatalf("Unexpected error: expected %v, got %v", impl.ErrInvalidSuffix, err)
}
@@ -149,13 +149,13 @@
if output, err = stubV1.Match(ctx, []string{"media"}); err != nil {
t.Fatalf("Match() failed: %v", err)
}
- if err := stubV1.Remove(ctx, "base"); err == nil || !verror.Is(err, impl.ErrNotFound.ID) {
+ if err := stubV1.Remove(ctx, "base"); err == nil || verror.ErrorID(err) != impl.ErrNotFound.ID {
t.Fatalf("Unexpected error: expected %v, got %v", impl.ErrNotFound, err)
}
if err := stub.Remove(ctx, "base"); err != nil {
t.Fatalf("Remove() failed: %v", err)
}
- if err := stubV2.Remove(ctx, "media"); err == nil || !verror.Is(err, impl.ErrNotFound.ID) {
+ if err := stubV2.Remove(ctx, "media"); err == nil || verror.ErrorID(err) != impl.ErrNotFound.ID {
t.Fatalf("Unexpected error: expected %v, got %v", impl.ErrNotFound, err)
}
if err := stubV1.Remove(ctx, "media"); err != nil {
@@ -164,13 +164,13 @@
// Finally, use Match() to test that Remove really removed the
// application envelopes.
- if _, err := stubV1.Match(ctx, []string{"base"}); err == nil || !verror.Is(err, impl.ErrNotFound.ID) {
+ if _, err := stubV1.Match(ctx, []string{"base"}); err == nil || verror.ErrorID(err) != impl.ErrNotFound.ID {
t.Fatalf("Unexpected error: expected %v, got %v", impl.ErrNotFound, err)
}
- if _, err := stubV1.Match(ctx, []string{"media"}); err == nil || !verror.Is(err, impl.ErrNotFound.ID) {
+ if _, err := stubV1.Match(ctx, []string{"media"}); err == nil || verror.ErrorID(err) != impl.ErrNotFound.ID {
t.Fatalf("Unexpected error: expected %v, got %v", impl.ErrNotFound, err)
}
- if _, err := stubV2.Match(ctx, []string{"base"}); err == nil || !verror.Is(err, impl.ErrNotFound.ID) {
+ if _, err := stubV2.Match(ctx, []string{"base"}); err == nil || verror.ErrorID(err) != impl.ErrNotFound.ID {
t.Fatalf("Unexpected error: expected %v, got %v", impl.ErrNotFound, err)
}
diff --git a/services/mgmt/application/impl/service.go b/services/mgmt/application/impl/service.go
index ac6545e..0ffb770 100644
--- a/services/mgmt/application/impl/service.go
+++ b/services/mgmt/application/impl/service.go
@@ -250,7 +250,7 @@
func getAccessList(store *fs.Memstore, path string) (access.Permissions, string, error) {
entry, err := store.BindObject(path).Get(nil)
- if verror.Is(err, fs.ErrNotInMemStore.ID) {
+ if verror.ErrorID(err) == fs.ErrNotInMemStore.ID {
// No AccessList exists
return nil, "", verror.New(ErrNotFound, nil)
} else if err != nil {
@@ -274,7 +274,7 @@
// where path is expected to have already been cleaned by naming.Join.
func setAccessList(store *fs.Memstore, path string, acl access.Permissions, etag string) error {
_, oetag, err := getAccessList(store, path)
- if verror.Is(err, ErrNotFound.ID) {
+ if verror.ErrorID(err) == ErrNotFound.ID {
oetag = etag
} else if err != nil {
return err
diff --git a/services/mgmt/binary/impl/acl_test.go b/services/mgmt/binary/impl/acl_test.go
index c7f357f..4670f36 100644
--- a/services/mgmt/binary/impl/acl_test.go
+++ b/services/mgmt/binary/impl/acl_test.go
@@ -192,10 +192,10 @@
}
vlog.VI(2).Infof("Verify that in the beginning other can't access bini/private or bini/shared")
- if _, _, err := b("bini/private").Stat(otherCtx); !verror.Is(err, verror.ErrNoAccess.ID) {
+ if _, _, err := b("bini/private").Stat(otherCtx); verror.ErrorID(err) != verror.ErrNoAccess.ID {
t.Fatalf("Stat() should have failed but didn't: %v", err)
}
- if _, _, err := b("bini/shared").Stat(otherCtx); !verror.Is(err, verror.ErrNoAccess.ID) {
+ if _, _, err := b("bini/shared").Stat(otherCtx); verror.ErrorID(err) != verror.ErrNoAccess.ID {
t.Fatalf("Stat() should have failed but didn't: %v", err)
}
@@ -263,7 +263,7 @@
// root level. Self has to set one explicitly to enable sharing. This way, self
// can't accidentally expose the server without setting a root AccessList.
vlog.VI(2).Infof(" Verify that other still can't access bini/shared.")
- if _, _, err := b("bini/shared").Stat(otherCtx); !verror.Is(err, verror.ErrNoAccess.ID) {
+ if _, _, err := b("bini/shared").Stat(otherCtx); verror.ErrorID(err) != verror.ErrNoAccess.ID {
t.Fatalf("Stat() should have failed but didn't: %v", err)
}
@@ -280,7 +280,7 @@
if _, _, err := b("bini/shared").Stat(otherCtx); err != nil {
t.Fatalf("Stat() shouldn't have failed: %v", err)
}
- if _, _, err := b("bini/private").Stat(otherCtx); !verror.Is(err, verror.ErrNoAccess.ID) {
+ if _, _, err := b("bini/private").Stat(otherCtx); verror.ErrorID(err) != verror.ErrNoAccess.ID {
t.Fatalf("Stat() should have failed but didn't: %v", err)
}
@@ -380,7 +380,7 @@
}
vlog.VI(2).Infof("And now other can do nothing at affecting the root. Other should be penitent.")
- if err := b("bini/nototherbinary").Create(otherCtx, 1, repository.MediaInfo{Type: "application/octet-stream"}); !verror.Is(err, verror.ErrNoAccess.ID) {
+ if err := b("bini/nototherbinary").Create(otherCtx, 1, repository.MediaInfo{Type: "application/octet-stream"}); verror.ErrorID(err) != verror.ErrNoAccess.ID {
t.Fatalf("Create() should have failed %v", err)
}
@@ -402,7 +402,7 @@
t.Fatalf("SetPermissions() failed: %v", err)
}
vlog.VI(2).Infof("And now other can't access shared either.")
- if _, _, err := b("bini/shared").Stat(otherCtx); !verror.Is(err, verror.ErrNoAccess.ID) {
+ if _, _, err := b("bini/shared").Stat(otherCtx); verror.ErrorID(err) != verror.ErrNoAccess.ID {
t.Fatalf("Stat() should have failed but didn't: %v", err)
}
// TODO(rjkroege): Extend the test with a third principal and verify that
diff --git a/services/mgmt/binary/impl/impl_test.go b/services/mgmt/binary/impl/impl_test.go
index 836d5ae..4f308e4 100644
--- a/services/mgmt/binary/impl/impl_test.go
+++ b/services/mgmt/binary/impl/impl_test.go
@@ -252,7 +252,7 @@
}
if err := binary.Create(ctx, int32(length), repository.MediaInfo{Type: "application/octet-stream"}); err == nil {
t.Fatalf("Create() did not fail when it should have")
- } else if want := verror.ErrExist.ID; !verror.Is(err, want) {
+ } else if want := verror.ErrExist.ID; verror.ErrorID(err) != want {
t.Fatalf("Unexpected error: %v, expected error id %v", err, want)
}
if streamErr, err := invokeUpload(t, ctx, binary, data[0], 0); streamErr != nil || err != nil {
@@ -260,12 +260,12 @@
}
if _, err := invokeUpload(t, ctx, binary, data[0], 0); err == nil {
t.Fatalf("Upload() did not fail when it should have")
- } else if want := verror.ErrExist.ID; !verror.Is(err, want) {
+ } else if want := verror.ErrExist.ID; verror.ErrorID(err) != want {
t.Fatalf("Unexpected error: %v, expected error id %v", err, want)
}
if _, _, err := invokeDownload(t, ctx, binary, 1); err == nil {
t.Fatalf("Download() did not fail when it should have")
- } else if want := verror.ErrNoExist.ID; !verror.Is(err, want) {
+ } else if want := verror.ErrNoExist.ID; verror.ErrorID(err) != want {
t.Fatalf("Unexpected error: %v, expected error id %v", err, want)
}
if streamErr, err := invokeUpload(t, ctx, binary, data[1], 1); streamErr != nil || err != nil {
@@ -279,12 +279,12 @@
for _, part := range []int32{-1, length} {
if _, err := invokeUpload(t, ctx, binary, []byte("dummy"), part); err == nil {
t.Fatalf("Upload() did not fail when it should have")
- } else if want := impl.ErrInvalidPart.ID; !verror.Is(err, want) {
+ } else if want := impl.ErrInvalidPart.ID; verror.ErrorID(err) != want {
t.Fatalf("Unexpected error: %v, expected error id %v", err, want)
}
if _, _, err := invokeDownload(t, ctx, binary, part); err == nil {
t.Fatalf("Download() did not fail when it should have")
- } else if want := impl.ErrInvalidPart.ID; !verror.Is(err, want) {
+ } else if want := impl.ErrInvalidPart.ID; verror.ErrorID(err) != want {
t.Fatalf("Unexpected error: %v, expected error id %v", err, want)
}
}
@@ -293,7 +293,7 @@
}
if err := binary.Delete(ctx); err == nil {
t.Fatalf("Delete() did not fail when it should have")
- } else if want := verror.ErrNoExist.ID; !verror.Is(err, want) {
+ } else if want := verror.ErrNoExist.ID; verror.ErrorID(err) != want {
t.Fatalf("Unexpected error: %v, expected error id %v", err, want)
}
}
diff --git a/services/mgmt/binary/impl/service.go b/services/mgmt/binary/impl/service.go
index 072c088..d7fa896 100644
--- a/services/mgmt/binary/impl/service.go
+++ b/services/mgmt/binary/impl/service.go
@@ -310,7 +310,7 @@
err := checksumExists(path)
if err == nil {
return verror.New(verror.ErrExist, call.Context(), path)
- } else if !verror.Is(err, verror.ErrNoExist.ID) {
+ } else if verror.ErrorID(err) != verror.ErrNoExist.ID {
return err
}
// Use os.OpenFile() to resolve races.
diff --git a/services/mgmt/debug/dispatcher_test.go b/services/mgmt/debug/dispatcher_test.go
index eb39567..40e89f2 100644
--- a/services/mgmt/debug/dispatcher_test.go
+++ b/services/mgmt/debug/dispatcher_test.go
@@ -118,7 +118,7 @@
{
lf := logreader.LogFileClient(naming.JoinAddressName(endpoint, "debug/logs/nosuchfile.INFO"))
_, err = lf.Size(tracedContext(ctx))
- if expected := verror.ErrNoExist.ID; !verror.Is(err, expected) {
+ if expected := verror.ErrNoExist.ID; verror.ErrorID(err) != expected {
t.Errorf("unexpected error value, got %v, want: %v", err, expected)
}
}
@@ -142,7 +142,7 @@
{
st := stats.StatsClient(naming.JoinAddressName(endpoint, "debug/stats/testing/nobodyhome"))
_, err = st.Value(tracedContext(ctx))
- if expected := verror.ErrNoExist.ID; !verror.Is(err, expected) {
+ if expected := verror.ErrNoExist.ID; verror.ErrorID(err) != expected {
t.Errorf("unexpected error value, got %v, want: %v", err, expected)
}
}
diff --git a/services/mgmt/device/impl/app_service.go b/services/mgmt/device/impl/app_service.go
index f552a00..2d55533 100644
--- a/services/mgmt/device/impl/app_service.go
+++ b/services/mgmt/device/impl/app_service.go
@@ -1028,7 +1028,7 @@
if err != nil {
return err
}
- if err := transitionInstance(instanceDir, device.InstanceStateSuspended, device.InstanceStateStopped); verror.Is(err, ErrOperationFailed.ID) || err == nil {
+ if err := transitionInstance(instanceDir, device.InstanceStateSuspended, device.InstanceStateStopped); verror.ErrorID(err) == ErrOperationFailed.ID || err == nil {
return err
}
if err := transitionInstance(instanceDir, device.InstanceStateStarted, device.InstanceStateStopping); err != nil {
diff --git a/services/mgmt/device/impl/debug_acls_test.go b/services/mgmt/device/impl/debug_acls_test.go
index fe45b47..40cd3d8 100644
--- a/services/mgmt/device/impl/debug_acls_test.go
+++ b/services/mgmt/device/impl/debug_acls_test.go
@@ -33,7 +33,7 @@
}
func testAccessFail(t *testing.T, expected verror.ID, ctx *context.T, who string, name ...string) {
- if _, err := statsStub(name...).Value(ctx); !verror.Is(err, expected) {
+ if _, err := statsStub(name...).Value(ctx); verror.ErrorID(err) != expected {
t.Fatalf(testutil.FormatLogLine(2, "%s got error %v but expected %v", who, err, expected))
}
}
diff --git a/services/mgmt/device/impl/impl_test.go b/services/mgmt/device/impl/impl_test.go
index 9994b97..32d6c9f 100644
--- a/services/mgmt/device/impl/impl_test.go
+++ b/services/mgmt/device/impl/impl_test.go
@@ -1682,7 +1682,7 @@
if _, err := libbinary.Upload(ctx, naming.Join(binaryVON, "testbinary"), up, mediaInfo); err != nil {
t.Fatalf("Upload(%v) failed:%v", binaryVON, err)
}
- if _, err := appStub().Install(ctx, mockApplicationRepoName, device.Config{}, nil); !verror.Is(err, impl.ErrOperationFailed.ID) {
+ if _, err := appStub().Install(ctx, mockApplicationRepoName, device.Config{}, nil); verror.ErrorID(err) != impl.ErrOperationFailed.ID {
t.Fatalf("Failed to verify signature mismatch for binary:%v. Got errorid=%v[%v], want errorid=%v", binaryVON, verror.ErrorID(err), err, impl.ErrOperationFailed.ID)
}
@@ -1712,7 +1712,7 @@
if _, err = libbinary.UploadFromDir(ctx, pkgVON, tmpdir); err != nil {
t.Fatalf("libbinary.UploadFromDir failed: %v", err)
}
- if _, err := appStub().Install(ctx, mockApplicationRepoName, device.Config{}, nil); !verror.Is(err, impl.ErrOperationFailed.ID) {
+ if _, err := appStub().Install(ctx, mockApplicationRepoName, device.Config{}, nil); verror.ErrorID(err) != impl.ErrOperationFailed.ID {
t.Fatalf("Failed to verify signature mismatch for package:%v", pkgVON)
}
}
diff --git a/services/mgmt/device/impl/util_test.go b/services/mgmt/device/impl/util_test.go
index f6e067c..6eec044 100644
--- a/services/mgmt/device/impl/util_test.go
+++ b/services/mgmt/device/impl/util_test.go
@@ -61,7 +61,7 @@
func resolveExpectNotFound(t *testing.T, ctx *context.T, name string) {
if me, err := v23.GetNamespace(ctx).Resolve(ctx, name); err == nil {
t.Fatalf(testutil.FormatLogLine(2, "Resolve(%v) succeeded with results %v when it was expected to fail", name, me.Names()))
- } else if expectErr := naming.ErrNoSuchName.ID; !verror.Is(err, expectErr) {
+ } else if expectErr := naming.ErrNoSuchName.ID; verror.ErrorID(err) != expectErr {
t.Fatalf(testutil.FormatLogLine(2, "Resolve(%v) failed with error %v, expected error ID %v", name, err, expectErr))
}
}
@@ -109,7 +109,7 @@
// AlreadyClaimed)
start := time.Now()
for {
- if err := device.ClaimableClient(name).Claim(ctx, pairingToken, g, s); !verror.Is(err, impl.ErrDeviceAlreadyClaimed.ID) {
+ if err := device.ClaimableClient(name).Claim(ctx, pairingToken, g, s); verror.ErrorID(err) != impl.ErrDeviceAlreadyClaimed.ID {
return
}
vlog.VI(4).Infof("Claimable server at %q has not stopped yet", name)
@@ -125,13 +125,13 @@
g := &granter{p: v23.GetPrincipal(ctx), extension: extension}
s := options.SkipServerEndpointAuthorization{}
// Call the Claim RPC
- if err := device.ClaimableClient(name).Claim(ctx, pairingToken, g, s); !verror.Is(err, errID) {
+ if err := device.ClaimableClient(name).Claim(ctx, pairingToken, g, s); verror.ErrorID(err) != errID {
t.Fatalf(testutil.FormatLogLine(2, "%q.Claim(%q) expected to fail with %v, got %v [%v]", name, pairingToken, errID, verror.ErrorID(err), err))
}
}
func updateDeviceExpectError(t *testing.T, ctx *context.T, name string, errID verror.ID) {
- if err := deviceStub(name).Update(ctx); !verror.Is(err, errID) {
+ if err := deviceStub(name).Update(ctx); verror.ErrorID(err) != errID {
t.Fatalf(testutil.FormatLogLine(2, "%q.Update expected to fail with %v, got %v [%v]", name, errID, verror.ErrorID(err), err))
}
}
@@ -143,7 +143,7 @@
}
func revertDeviceExpectError(t *testing.T, ctx *context.T, name string, errID verror.ID) {
- if err := deviceStub(name).Revert(ctx); !verror.Is(err, errID) {
+ if err := deviceStub(name).Revert(ctx); verror.ErrorID(err) != errID {
t.Fatalf(testutil.FormatLogLine(2, "%q.Revert() expected to fail with %v, got %v [%v]", name, errID, verror.ErrorID(err), err))
}
}
@@ -207,7 +207,7 @@
}
func installAppExpectError(t *testing.T, ctx *context.T, expectedError verror.ID, opt ...interface{}) {
- if _, err := appStub().Install(ctx, mockApplicationRepoName, ocfg(opt), opkg(opt)); err == nil || !verror.Is(err, expectedError) {
+ if _, err := appStub().Install(ctx, mockApplicationRepoName, ocfg(opt), opkg(opt)); err == nil || verror.ErrorID(err) != expectedError {
t.Fatalf(testutil.FormatLogLine(2, "Install expected to fail with %v, got %v [%v]", expectedError, verror.ErrorID(err), err))
}
}
@@ -268,7 +268,7 @@
}
func startAppExpectError(t *testing.T, ctx *context.T, appID string, expectedError verror.ID) {
- if _, err := startAppImpl(t, ctx, appID, "forapp"); err == nil || !verror.Is(err, expectedError) {
+ if _, err := startAppImpl(t, ctx, appID, "forapp"); err == nil || verror.ErrorID(err) != expectedError {
t.Fatalf(testutil.FormatLogLine(2, "Start(%v) expected to fail with %v, got %v [%v]", appID, expectedError, verror.ErrorID(err), err))
}
}
@@ -292,7 +292,7 @@
}
func resumeAppExpectError(t *testing.T, ctx *context.T, appID, instanceID string, expectedError verror.ID) {
- if err := appStub(appID, instanceID).Resume(ctx); err == nil || !verror.Is(err, expectedError) {
+ if err := appStub(appID, instanceID).Resume(ctx); err == nil || verror.ErrorID(err) != expectedError {
t.Fatalf(testutil.FormatLogLine(2, "Resume(%v/%v) expected to fail with %v, got %v [%v]", appID, instanceID, expectedError, verror.ErrorID(err), err))
}
}
@@ -304,7 +304,7 @@
}
func updateInstanceExpectError(t *testing.T, ctx *context.T, appID, instanceID string, expectedError verror.ID) {
- if err := appStub(appID, instanceID).Update(ctx); err == nil || !verror.Is(err, expectedError) {
+ if err := appStub(appID, instanceID).Update(ctx); err == nil || verror.ErrorID(err) != expectedError {
t.Fatalf(testutil.FormatLogLine(2, "Update(%v/%v) expected to fail with %v, got %v [%v]", appID, instanceID, expectedError, verror.ErrorID(err), err))
}
}
@@ -316,7 +316,7 @@
}
func updateAppExpectError(t *testing.T, ctx *context.T, appID string, expectedError verror.ID) {
- if err := appStub(appID).Update(ctx); err == nil || !verror.Is(err, expectedError) {
+ if err := appStub(appID).Update(ctx); err == nil || verror.ErrorID(err) != expectedError {
t.Fatalf(testutil.FormatLogLine(2, "Update(%v) expected to fail with %v, got %v [%v]", appID, expectedError, verror.ErrorID(err), err))
}
}
@@ -328,7 +328,7 @@
}
func revertAppExpectError(t *testing.T, ctx *context.T, appID string, expectedError verror.ID) {
- if err := appStub(appID).Revert(ctx); err == nil || !verror.Is(err, expectedError) {
+ if err := appStub(appID).Revert(ctx); err == nil || verror.ErrorID(err) != expectedError {
t.Fatalf(testutil.FormatLogLine(2, "Revert(%v) expected to fail with %v, got %v [%v]", appID, expectedError, verror.ErrorID(err), err))
}
}
diff --git a/services/mgmt/lib/fs/simplestore_test.go b/services/mgmt/lib/fs/simplestore_test.go
index 2d092b3..df723d3 100644
--- a/services/mgmt/lib/fs/simplestore_test.go
+++ b/services/mgmt/lib/fs/simplestore_test.go
@@ -251,17 +251,17 @@
}
// At which point, Get() on the transaction won't find anything.
- if _, err := memstoreOriginal.BindObject(fs.TP("/test/a")).Get(nil); !verror.Is(err, fs.ErrNotInMemStore.ID) {
+ if _, err := memstoreOriginal.BindObject(fs.TP("/test/a")).Get(nil); verror.ErrorID(err) != fs.ErrNotInMemStore.ID {
t.Fatalf("Get() should have failed: got %v, expected %v", err, verror.New(fs.ErrNotInMemStore, nil, tname+"/test/a"))
}
// Attempting to Remove() it over again will fail.
- if err := memstoreOriginal.BindObject(fs.TP("/test/a")).Remove(nil); !verror.Is(err, fs.ErrNotInMemStore.ID) {
+ if err := memstoreOriginal.BindObject(fs.TP("/test/a")).Remove(nil); verror.ErrorID(err) != fs.ErrNotInMemStore.ID {
t.Fatalf("Remove() should have failed: got %v, expected %v", err, verror.New(fs.ErrNotInMemStore, nil, tname+"/test/a"))
}
// Attempting to Remove() a non-existing path will fail.
- if err := memstoreOriginal.BindObject(fs.TP("/foo")).Remove(nil); !verror.Is(err, fs.ErrNotInMemStore.ID) {
+ if err := memstoreOriginal.BindObject(fs.TP("/foo")).Remove(nil); verror.ErrorID(err) != fs.ErrNotInMemStore.ID {
t.Fatalf("Remove() should have failed: got %v, expected %v", err, verror.New(fs.ErrNotInMemStore, nil, tname+"/foo"))
}
@@ -286,7 +286,7 @@
}
// Validate that Get will fail on a non-existent path.
- if _, err := memstoreOriginal.BindObject("/test/c").Get(nil); !verror.Is(err, fs.ErrNotInMemStore.ID) {
+ if _, err := memstoreOriginal.BindObject("/test/c").Get(nil); verror.ErrorID(err) != fs.ErrNotInMemStore.ID {
t.Fatalf("Get() should have failed: got %v, expected %v", err, verror.New(fs.ErrNotInMemStore, nil, tname+"/test/c"))
}
@@ -409,17 +409,17 @@
// Put outside ot a transaction should fail.
bindingTnameTestA := memstoreOriginal.BindObject(naming.Join("fooey", "/test/a"))
- if _, err := bindingTnameTestA.Put(nil, envelope); !verror.Is(err, fs.ErrWithoutTransaction.ID) {
+ if _, err := bindingTnameTestA.Put(nil, envelope); verror.ErrorID(err) != fs.ErrWithoutTransaction.ID {
t.Fatalf("Put() failed: got %v, expected %v", err, verror.New(fs.ErrWithoutTransaction, nil, "Put()"))
}
// Remove outside of a transaction should fail
- if err := bindingTnameTestA.Remove(nil); !verror.Is(err, fs.ErrWithoutTransaction.ID) {
+ if err := bindingTnameTestA.Remove(nil); verror.ErrorID(err) != fs.ErrWithoutTransaction.ID {
t.Fatalf("Put() failed: got %v, expected %v", err, verror.New(fs.ErrWithoutTransaction, nil, "Remove()"))
}
// Commit outside of a transaction should fail
- if err := memstoreOriginal.BindTransaction(tname).Commit(nil); !verror.Is(err, fs.ErrDoubleCommit.ID) {
+ if err := memstoreOriginal.BindTransaction(tname).Commit(nil); verror.ErrorID(err) != fs.ErrDoubleCommit.ID {
t.Fatalf("Commit() failed: got %v, expected %v", err, verror.New(fs.ErrDoubleCommit, nil))
}
@@ -438,7 +438,7 @@
memstoreOriginal.Unlock()
// Remove should definitely fail on an abndonned transaction.
- if err := bindingTnameTestB.Remove(nil); !verror.Is(err, fs.ErrWithoutTransaction.ID) {
+ if err := bindingTnameTestB.Remove(nil); verror.ErrorID(err) != fs.ErrWithoutTransaction.ID {
t.Fatalf("Remove() failed: got %v, expected %v", err, verror.New(fs.ErrWithoutTransaction, nil, "Remove()"))
}
}
diff --git a/services/mgmt/logreader/impl/logfile_test.go b/services/mgmt/logreader/impl/logfile_test.go
index 7678d8c..94593e5 100644
--- a/services/mgmt/logreader/impl/logfile_test.go
+++ b/services/mgmt/logreader/impl/logfile_test.go
@@ -101,7 +101,7 @@
// Try to access a file that doesn't exist.
lf := logreader.LogFileClient(naming.JoinAddressName(endpoint, "doesntexist"))
_, err = lf.Size(ctx)
- if expected := verror.ErrNoExist.ID; !verror.Is(err, expected) {
+ if expected := verror.ErrNoExist.ID; verror.ErrorID(err) != expected {
t.Errorf("unexpected error value, got %v, want: %v", err, expected)
}
@@ -147,7 +147,7 @@
t.Errorf("ReadLog failed: %v", err)
}
_, err = stream.Finish()
- if !verror.Is(err, verror.ErrEndOfFile.ID) {
+ if verror.ErrorID(err) != verror.ErrEndOfFile.ID {
t.Errorf("unexpected error, got %#v, want EOF", err)
}
}
diff --git a/services/security/groups/server/server_test.go b/services/security/groups/server/server_test.go
index c1de821..666a156 100644
--- a/services/security/groups/server/server_test.go
+++ b/services/security/groups/server/server_test.go
@@ -173,7 +173,7 @@
// Creating same group again should fail, since the group already exists.
g = groups.GroupClient(naming.JoinAddressName(serverName, "grpA"))
- if err := g.Create(ctx, nil, nil); !verror.Is(err, verror.ErrExist.ID) {
+ if err := g.Create(ctx, nil, nil); verror.ErrorID(err) != verror.ErrExist.ID {
t.Fatal("Create should have failed")
}
@@ -211,7 +211,7 @@
t.Fatal("Create failed: ", err)
}
// Delete with bad etag should fail.
- if err := g.Delete(ctx, "20"); !verror.Is(err, verror.ErrBadEtag.ID) {
+ if err := g.Delete(ctx, "20"); verror.ErrorID(err) != verror.ErrBadEtag.ID {
t.Fatal("Delete should have failed with etag error")
}
// Delete with correct etag should succeed.
@@ -220,7 +220,7 @@
t.Fatal("Delete failed: ", err)
}
// Check that the group was actually deleted.
- if _, _, err := g.Get(ctx, groups.GetRequest{}, ""); !verror.Is(err, verror.ErrNoExistOrNoAccess.ID) {
+ if _, _, err := g.Get(ctx, groups.GetRequest{}, ""); verror.ErrorID(err) != verror.ErrNoExistOrNoAccess.ID {
t.Fatal("Group was not deleted")
}
@@ -234,7 +234,7 @@
t.Fatal("Delete failed: ", err)
}
// Check that the group was actually deleted.
- if _, _, err := g.Get(ctx, groups.GetRequest{}, ""); !verror.Is(err, verror.ErrNoExistOrNoAccess.ID) {
+ if _, _, err := g.Get(ctx, groups.GetRequest{}, ""); verror.ErrorID(err) != verror.ErrNoExistOrNoAccess.ID {
t.Fatal("Group was not deleted")
}
// Check that we can recreate a group that was deleted.
@@ -251,7 +251,7 @@
t.Fatal("Create failed: ", err)
}
// Delete should fail (no access).
- if err := g.Delete(ctx, ""); !verror.Is(err, verror.ErrNoExistOrNoAccess.ID) {
+ if err := g.Delete(ctx, ""); verror.ErrorID(err) != verror.ErrNoExistOrNoAccess.ID {
t.Fatal("Delete should have failed with access error")
}
}
@@ -288,7 +288,7 @@
// SetPermissions with bad etag should fail.
aclBefore, etagBefore = getAccessListAndEtagOrDie()
- if err := g.SetPermissions(ctx, myacl, "20"); !verror.Is(err, verror.ErrBadEtag.ID) {
+ if err := g.SetPermissions(ctx, myacl, "20"); verror.ErrorID(err) != verror.ErrBadEtag.ID {
t.Fatal("SetPermissions should have failed with etag error")
}
// Since SetPermissions failed, the AccessList and etag should not have changed.
@@ -347,10 +347,10 @@
if err := g.SetPermissions(ctx, access.Permissions{}, ""); err != nil {
t.Fatal("SetPermissions failed: ", err)
}
- if _, _, err := g.GetPermissions(ctx); !verror.Is(err, verror.ErrNoExistOrNoAccess.ID) {
+ if _, _, err := g.GetPermissions(ctx); verror.ErrorID(err) != verror.ErrNoExistOrNoAccess.ID {
t.Fatal("GetPermissions should have failed with access error")
}
- if err := g.SetPermissions(ctx, myacl, ""); !verror.Is(err, verror.ErrNoExistOrNoAccess.ID) {
+ if err := g.SetPermissions(ctx, myacl, ""); verror.ErrorID(err) != verror.ErrNoExistOrNoAccess.ID {
t.Fatal("SetPermissions should have failed with access error")
}
}
@@ -374,7 +374,7 @@
var etagBefore, etagAfter string
etagBefore = getEtagOrDie(g, ctx, t)
// Add with bad etag should fail.
- if err := g.Add(ctx, bpc("foo"), "20"); !verror.Is(err, verror.ErrBadEtag.ID) {
+ if err := g.Add(ctx, bpc("foo"), "20"); verror.ErrorID(err) != verror.ErrBadEtag.ID {
t.Fatal("Add should have failed with etag error")
}
// Etag should not have changed.
@@ -435,7 +435,7 @@
t.Fatal("Create failed: ", err)
}
// Add should fail (no access).
- if err := g.Add(ctx, bpc("foo"), ""); !verror.Is(err, verror.ErrNoExistOrNoAccess.ID) {
+ if err := g.Add(ctx, bpc("foo"), ""); verror.ErrorID(err) != verror.ErrNoExistOrNoAccess.ID {
t.Fatal("Add should have failed with access error")
}
}
@@ -459,7 +459,7 @@
var etagBefore, etagAfter string
etagBefore = getEtagOrDie(g, ctx, t)
// Remove with bad etag should fail.
- if err := g.Remove(ctx, bpc("foo"), "20"); !verror.Is(err, verror.ErrBadEtag.ID) {
+ if err := g.Remove(ctx, bpc("foo"), "20"); verror.ErrorID(err) != verror.ErrBadEtag.ID {
t.Fatal("Remove should have failed with etag error")
}
// Etag should not have changed.
@@ -520,7 +520,7 @@
t.Fatal("Create failed: ", err)
}
// Remove should fail (no access).
- if err := g.Remove(ctx, bpc("foo"), ""); !verror.Is(err, verror.ErrNoExistOrNoAccess.ID) {
+ if err := g.Remove(ctx, bpc("foo"), ""); verror.ErrorID(err) != verror.ErrNoExistOrNoAccess.ID {
t.Fatal("Remove should have failed with access error")
}
}
diff --git a/services/wsprd/app/app_test.go b/services/wsprd/app/app_test.go
index 974d061..8c75b0a 100644
--- a/services/wsprd/app/app_test.go
+++ b/services/wsprd/app/app_test.go
@@ -450,11 +450,7 @@
var result *vdl.Value
err = call.Finish(&result)
- // If err is nil and testCase.err is nil reflect.DeepEqual will return
- // false because the types are different. Because of this, we only use
- // reflect.DeepEqual if one of the values is non-nil. If both values
- // are nil, then we consider them equal.
- if (err != nil || testCase.err != nil) && !verror.Equal(err, testCase.err) {
+ if verror.ErrorID(err) != verror.ErrorID(testCase.err) {
t.Errorf("unexpected err: got %#v, expected %#v", err, testCase.err)
}
diff --git a/services/wsprd/app/messaging.go b/services/wsprd/app/messaging.go
index 5ea5a40..22a092e 100644
--- a/services/wsprd/app/messaging.go
+++ b/services/wsprd/app/messaging.go
@@ -179,7 +179,7 @@
if _, file, line, ok := runtime.Caller(3); ok {
logErr = fmt.Sprintf("%s:%d: %s", filepath.Base(file), line, logErr)
}
- if verror.Is(verr, verror.ErrInternal.ID) {
+ if verror.ErrorID(verr) == verror.ErrInternal.ID {
logLevel = 2
}
vlog.VI(logLevel).Info(logErr)
diff --git a/services/wsprd/lib/testwriter/writer.go b/services/wsprd/lib/testwriter/writer.go
index 6aec6dc..65dabb9 100644
--- a/services/wsprd/lib/testwriter/writer.go
+++ b/services/wsprd/lib/testwriter/writer.go
@@ -105,7 +105,7 @@
if got, want := w.Stream, wantStream; !reflect.DeepEqual(got, want) {
return fmt.Errorf("streams don't match: got %#v, want %#v", got, want)
}
- if got, want := w.err, wantErr; !verror.Equal(got, want) {
+ if got, want := w.err, wantErr; verror.ErrorID(got) != verror.ErrorID(want) {
return fmt.Errorf("unexpected error, got: %#v, expected: %#v", got, want)
}
return nil
diff --git a/services/wsprd/principal/util_test.go b/services/wsprd/principal/util_test.go
index 80bf068..7ee21ed 100644
--- a/services/wsprd/principal/util_test.go
+++ b/services/wsprd/principal/util_test.go
@@ -40,7 +40,7 @@
if got == nil {
return fmt.Errorf("Got nil error, wanted to match %q", want)
}
- if !verror.Is(got, want) {
+ if verror.ErrorID(got) != want {
return fmt.Errorf("Got error %q, wanted to match %q", got, want)
}
return nil
diff --git a/services/wsprd/wspr/writer.go b/services/wsprd/wspr/writer.go
index 3fe0917..956c6bb 100644
--- a/services/wsprd/wspr/writer.go
+++ b/services/wsprd/wspr/writer.go
@@ -64,7 +64,7 @@
if _, file, line, ok := runtime.Caller(3); ok {
logErr = fmt.Sprintf("%s:%d: %s", filepath.Base(file), line, logErr)
}
- if verror.Is(verr, verror.ErrInternal.ID) {
+ if verror.ErrorID(verr) == verror.ErrInternal.ID {
logLevel = 2
}
vlog.VI(logLevel).Info(logErr)