v.io/x/ref/security: Use verror instead of fmt.Errorf and errors.New
This changed uses verror instead of fmt.Errorf and errors.New
in all non-test code in v.io/x/ref/security.
Local variables are used for the error codess except for the
error code ErrBadPassphrase in util.go, which corresponds to the
error (as opposed to error code) PassphraseErr in the old code.
The new variable is exported only because the old one was.
In most cases the error codesare defined in the single file where
they are used. In a few cases, such as ErrBadPassphrase and
errDataOrSignerUnspecified in blessingstore.go, the error code is
also used in one or more other modules.
In all cases, the error message is kept as much as possible as it
was. The only consistent addition is the "{1:}{2:} " at the
front to output the programme and operation (RPC) names.
Tested:
cd v.io
v23 go test ./...
v23 test run vanadium-go-test
Change-Id: Ic1809c4f6a332f039838cd76c681be9f3a72b4ed
diff --git a/security/blessingroots.go b/security/blessingroots.go
index ed4fc0a..d765905 100644
--- a/security/blessingroots.go
+++ b/security/blessingroots.go
@@ -6,7 +6,6 @@
import (
"bytes"
- "errors"
"fmt"
"sort"
"sync"
@@ -14,6 +13,7 @@
"v.io/x/ref/security/serialization"
"v.io/v23/security"
+ "v.io/v23/verror"
)
// blessingRoots implements security.BlessingRoots.
@@ -133,7 +133,7 @@
// also persists any updates to its state.
func newPersistingBlessingRoots(persistedData SerializerReaderWriter, signer serialization.Signer) (security.BlessingRoots, error) {
if persistedData == nil || signer == nil {
- return nil, errors.New("persisted data or signer is not specified")
+ return nil, verror.New(errDataOrSignerUnspecified, nil)
}
br := &blessingRoots{
store: make(map[string][]security.BlessingPattern),