v.io/x/ref/lib/stats: Use verror instead of fmt.Errorf or errors.New
This change replaces uses of fmt.Errorf and errors.New in lib/stats/...
with verror, and fixes up the dependencies.
The format strings are largely the same:
verror.NoExist is used instead of stats.ErrNotFound, and
stats.ErrNoValue (from services/mgmt/stats) is used instead of stats.ErrNoValue
Tested:
cd v.io
v23 go test ./...
v23 test run vanadium-go-test
Change-Id: I8459ce235b6bbd6c551dbb9cdd45b2116970a8ef
diff --git a/lib/stats/stats_test.go b/lib/stats/stats_test.go
index 60aa37d..be5f3ed 100644
--- a/lib/stats/stats_test.go
+++ b/lib/stats/stats_test.go
@@ -9,6 +9,7 @@
"testing"
"time"
+ "v.io/v23/verror"
libstats "v.io/x/ref/lib/stats"
"v.io/x/ref/lib/stats/counter"
"v.io/x/ref/lib/stats/histogram"
@@ -49,11 +50,11 @@
t.Errorf("unexpected result. Got %v, want %v", got, expected)
}
- if _, err := libstats.Value(""); err != libstats.ErrNotFound {
- t.Errorf("expected error, got err=%v", err)
+ if _, err := libstats.Value(""); verror.ErrorID(err) != verror.ErrNoExist.ID {
+ t.Errorf("expected error %s, got err=%s", verror.ErrNoExist.ID, verror.ErrorID(err))
}
- if _, err := libstats.Value("does/not/exist"); err != libstats.ErrNotFound {
- t.Errorf("expected error, got err=%v", err)
+ if _, err := libstats.Value("does/not/exist"); verror.ErrorID(err) != verror.ErrNoExist.ID {
+ t.Errorf("expected error %s, got err=%s", verror.ErrNoExist.ID, verror.ErrorID(err))
}
root := libstats.NewInteger("")
@@ -376,16 +377,16 @@
if err := libstats.Delete("a/b/c/d"); err != nil {
t.Errorf("unexpected error value: %v", err)
}
- if _, err := libstats.GetStatsObject("a/b/c/d"); err != libstats.ErrNotFound {
- t.Errorf("unexpected error value: Got %v, want %v", err, libstats.ErrNotFound)
+ if _, err := libstats.GetStatsObject("a/b/c/d"); verror.ErrorID(err) != verror.ErrNoExist.ID {
+ t.Errorf("unexpected error value: Got %v, want %v", verror.ErrorID(err), verror.ErrNoExist.ID)
}
if err := libstats.Delete("a/b"); err != nil {
t.Errorf("unexpected error value: %v", err)
}
- if _, err := libstats.GetStatsObject("a/b"); err != libstats.ErrNotFound {
- t.Errorf("unexpected error value: Got %v, want %v", err, libstats.ErrNotFound)
+ if _, err := libstats.GetStatsObject("a/b"); verror.ErrorID(err) != verror.ErrNoExist.ID {
+ t.Errorf("unexpected error value: Got %v, want %v", verror.ErrorID(err), verror.ErrNoExist.ID)
}
- if _, err := libstats.GetStatsObject("a/b/c"); err != libstats.ErrNotFound {
- t.Errorf("unexpected error value: Got %v, want %v", err, libstats.ErrNotFound)
+ if _, err := libstats.GetStatsObject("a/b/c"); verror.ErrorID(err) != verror.ErrNoExist.ID {
+ t.Errorf("unexpected error value: Got %v, want %v", verror.ErrorID(err), verror.ErrNoExist.ID)
}
}