Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
cosnicolaou committed Mar 21, 2024
1 parent fe89756 commit d7b0469
Show file tree
Hide file tree
Showing 12 changed files with 119 additions and 71 deletions.
18 changes: 9 additions & 9 deletions v23/flow/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import "v.io/v23/verror"
// These were previously defined in errors.vdl using the ID values
// below rather than the more conventional Err<Name>.
var (
ErrAuth = verror.NewID("Auth")
ErrNotTrusted = verror.NewID("NotTrusted")
ErrNetwork = verror.NewID("Network")
ErrDialFailed = verror.NewID("DialFailed")
ErrResolveFailed = verror.NewID("ResolveFailed")
ErrProxy = verror.NewID("Proxy")
ErrBadArg = verror.NewID("BadArg")
ErrBadState = verror.NewID("BadState")
ErrAborted = verror.NewID("Aborted")
ErrAuth = verror.NewID("v.io/v23/flow.Auth")
ErrNotTrusted = verror.NewID("v.io/v23/flow.NotTrusted")
ErrNetwork = verror.NewID("v.io/v23/flow.Network")
ErrDialFailed = verror.NewID("v.io/v23/flow.DialFailed")
ErrResolveFailed = verror.NewID("v.io/v23/flow.ResolveFailed")
ErrProxy = verror.NewID("v.io/v23/flow.Proxy")
ErrBadArg = verror.NewID("v.io/v23/flow.BadArg")
ErrBadState = verror.NewID("v.io/v23/flow.BadState")
ErrAborted = verror.NewID("v.io/v23/flow.Aborted")
)
8 changes: 4 additions & 4 deletions v23/flow/message/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import (
)

var (
ErrInvalidMsg = verror.NewID("InvalidMsg")
ErrInvalidSetupOption = verror.NewID("InvalidSetupOption")
ErrUnknownMsg = verror.NewID("UnknownMsg")
ErrMissingBlessings = verror.NewID("MissingBlessings")
ErrInvalidMsg = verror.NewID("v.io/v23/flow/messages.InvalidMsg")
ErrInvalidSetupOption = verror.NewID("v.io/v23/flow/messages.InvalidSetupOption")
ErrUnknownMsg = verror.NewID("v.io/v23/flow/messages.UnknownMsg")
ErrMissingBlessings = verror.NewID("v.io/v23/flow/messages.MissingBlessings")
)

// NewErrInvalidMsg creates an instance ErrInvalidMsg with the specified parameters which can be
Expand Down
10 changes: 5 additions & 5 deletions v23/naming/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ const (
)

var (
ErrNameExists = verror.NewID("nameExists")
ErrNoSuchName = verror.NewID("nameDoesntExist")
ErrNoSuchNameRoot = verror.NewID("rootNameDoesntExist")
ErrResolutionDepthExceeded = verror.NewID("resolutionDepthExceeded")
ErrNoMountTable = verror.NewID("noMounttable")
ErrNameExists = verror.NewID("v.io/v23/naming.nameExists")
ErrNoSuchName = verror.NewID("v.io/v23/naming.nameDoesntExist")
ErrNoSuchNameRoot = verror.NewID("v.io/v23/naming.rootNameDoesntExist")
ErrResolutionDepthExceeded = verror.NewID("v.io/v23/naming.resolutionDepthExceeded")
ErrNoMountTable = verror.NewID("v.io/v23/naming.noMounttable")
)

// Names returns the servers represented by MountEntry as names, including
Expand Down
6 changes: 5 additions & 1 deletion v23/verror/pkgpath.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,12 @@ func ensurePackagePath(id ID) ID {
if strings.Contains(sid, ".") && sid[0] != '.' {
return id
}
_, file, _, _ := runtime.Caller(2)
_, file, _, ok := runtime.Caller(2)
pkg := pkgPathCache.pkgPath(file)
if ok && file == "<autogenerated>" {
// See https://github.com/golang/go/issues/64520
panic("verror.NewID was called to initalize a global variable, move that initialization to an init function or specify the full package path in the ID\nNOTE that the stack trace shown below is not useful since its incorrect contents are the cause of the problem, see https://github.com/golang/go/issues/64520")
}
if len(pkg) == 0 {
return id
}
Expand Down
8 changes: 6 additions & 2 deletions v23/vom/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ import (
)

var (
errDumperClosed = verror.NewID("errDumperClosed")
errDumperFlushed = verror.NewID("errDumperFlushed")
errDumperClosed, errDumperFlushed verror.IDAction
)

func init() {
errDumperClosed = verror.NewID("errDumperClosed")
errDumperFlushed = verror.NewID("errDumperFlushed")
}

// Dump returns a human-readable dump of the given vom data, in the default
// string format.
func Dump(data []byte) (string, error) {
Expand Down
4 changes: 2 additions & 2 deletions x/ref/lib/security/principal.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import (

var (
// ErrBadPassphrase is a possible return error from LoadPersistentPrincipal()
ErrBadPassphrase = verror.NewID("errBadPassphrase")
ErrBadPassphrase = verror.NewID("v.io/x/ref/lib/security.errBadPassphrase")
// ErrPassphraseRequired is a possible return error from LoadPersistentPrincipal()
ErrPassphraseRequired = verror.NewID("errPassphraseRequired")
ErrPassphraseRequired = verror.NewID("v.io/x/ref/lib/security.errPassphraseRequired")
)

// NewPrincipal mints a new private (ecdsa) key and generates a principal
Expand Down
48 changes: 24 additions & 24 deletions x/ref/runtime/internal/flow/conn/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,28 @@ import "v.io/v23/verror"
// These were previously defined in errors.vdl using the ID values
// below rather than the more conventional Err<Name>.
var (
ErrMissingSetupOption = verror.NewID("MissingSetupOption")
ErrUnexpectedMsg = verror.NewID("UnexpectedMsg")
ErrConnectionClosed = verror.NewID("ConnectionClosed")
ErrRemoteError = verror.NewID("RemoteError")
ErrSend = verror.NewID("Send")
ErrRecv = verror.NewID("Recv")
ErrCounterOverflow = verror.NewID("CounterOverflow")
ErrBlessingsFlowClosed = verror.NewID("BlessingsFlowClosed")
ErrInvalidChannelBinding = verror.NewID("InvalidChannelBinding")
ErrNoPublicKey = verror.NewID("NoPublicKey")
ErrDialingNonServer = verror.NewID("DialingNonServer")
ErrAcceptorBlessingsMissing = verror.NewID("AcceptorBlessingsMissing")
ErrDialerBlessingsMissing = verror.NewID("DialerBlessingsMissing")
ErrBlessingsNotBound = verror.NewID("BlessingsNotBound")
ErrInvalidPeerFlow = verror.NewID("InvalidPeerFlow")
ErrChannelTimeout = verror.NewID("ChannelTimeout")
ErrCannotDecryptBlessings = verror.NewID("CannotDecryptBlessings")
ErrCannotDecryptDischarges = verror.NewID("CannotDecryptDischarges")
ErrCannotEncryptBlessings = verror.NewID("CannotEncryptBlessings")
ErrCannotEncryptDischarges = verror.NewID("CannotEncryptDischarges")
ErrNoCrypter = verror.NewID("NoCrypter")
ErrNoPrivateKey = verror.NewID("NoPrivateKey")
ErrIdleConnKilled = verror.NewID("IdleConnKilled")
ErrRPCVersionMismatch = verror.NewID("RPCVersionMismatch")
ErrMissingSetupOption = verror.NewID("v.io/x/ref/runtime/internal/flow/conn.MissingSetupOption")
ErrUnexpectedMsg = verror.NewID("v.io/x/ref/runtime/internal/flow/conn.UnexpectedMsg")
ErrConnectionClosed = verror.NewID("v.io/x/ref/runtime/internal/flow/conn.ConnectionClosed")
ErrRemoteError = verror.NewID("v.io/x/ref/runtime/internal/flow/conn.RemoteError")
ErrSend = verror.NewID("v.io/x/ref/runtime/internal/flow/conn.Send")
ErrRecv = verror.NewID("v.io/x/ref/runtime/internal/flow/conn.Recv")
ErrCounterOverflow = verror.NewID("v.io/x/ref/runtime/internal/flow/conn.CounterOverflow")
ErrBlessingsFlowClosed = verror.NewID("v.io/x/ref/runtime/internal/flow/conn.BlessingsFlowClosed")
ErrInvalidChannelBinding = verror.NewID("v.io/x/ref/runtime/internal/flow/conn.InvalidChannelBinding")
ErrNoPublicKey = verror.NewID("v.io/x/ref/runtime/internal/flow/conn.NoPublicKey")
ErrDialingNonServer = verror.NewID("v.io/x/ref/runtime/internal/flow/conn.DialingNonServer")
ErrAcceptorBlessingsMissing = verror.NewID("v.io/x/ref/runtime/internal/flow/conn.AcceptorBlessingsMissing")
ErrDialerBlessingsMissing = verror.NewID("v.io/x/ref/runtime/internal/flow/conn.DialerBlessingsMissing")
ErrBlessingsNotBound = verror.NewID("v.io/x/ref/runtime/internal/flow/conn.BlessingsNotBound")
ErrInvalidPeerFlow = verror.NewID("v.io/x/ref/runtime/internal/flow/conn.InvalidPeerFlow")
ErrChannelTimeout = verror.NewID("v.io/x/ref/runtime/internal/flow/conn.ChannelTimeout")
ErrCannotDecryptBlessings = verror.NewID("v.io/x/ref/runtime/internal/flow/conn.CannotDecryptBlessings")
ErrCannotDecryptDischarges = verror.NewID("v.io/x/ref/runtime/internal/flow/conn.CannotDecryptDischarges")
ErrCannotEncryptBlessings = verror.NewID("v.io/x/ref/runtime/internal/flow/conn.CannotEncryptBlessings")
ErrCannotEncryptDischarges = verror.NewID("v.io/x/ref/runtime/internal/flow/conn.CannotEncryptDischarges")
ErrNoCrypter = verror.NewID("v.io/x/ref/runtime/internal/flow/conn.NoCrypter")
ErrNoPrivateKey = verror.NewID("v.io/x/ref/runtime/internal/flow/conn.NoPrivateKey")
ErrIdleConnKilled = verror.NewID("v.io/x/ref/runtime/internal/flow/conn.IdleConnKilled")
ErrRPCVersionMismatch = verror.NewID("v.io/x/ref/runtime/internal/flow/conn.RPCVersionMismatch")
)
33 changes: 23 additions & 10 deletions x/ref/runtime/internal/flow/manager/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,27 @@ import "v.io/v23/verror"
var (
// These were defined in errors.vdl using the ID values
// below rather than the more conventional Err<Name>.
errUnknownProtocol = verror.NewID("UnknownProtocol")
errManagerClosed = verror.NewID("ManagerClosed")
errAcceptFailed = verror.NewID("AcceptFailed")
errCacheClosed = verror.NewID("CacheClosed")
errConnKilledToFreeResources = verror.NewID("ConnKilledToFreeResources")
errInvalidProxyResponse = verror.NewID("InvalidProxyResponse")
errListeningWithNullRid = verror.NewID("ListeningWithNullRid")
errProxyResponse = verror.NewID("ProxyResponse")
errNoBlessingsForPeer = verror.NewID("NoBlessingsForPeer")
errConnNotInCache = verror.NewID("ConnNotInCache")
errUnknownProtocol verror.IDAction
errManagerClosed verror.IDAction
errAcceptFailed verror.IDAction
errCacheClosed verror.IDAction
errConnKilledToFreeResources verror.IDAction
errInvalidProxyResponse verror.IDAction
errListeningWithNullRid verror.IDAction
errProxyResponse verror.IDAction
errNoBlessingsForPeer verror.IDAction
errConnNotInCache verror.IDAction
)

func init() {
errUnknownProtocol = verror.NewID("UnknownProtocol")
errManagerClosed = verror.NewID("ManagerClosed")
errAcceptFailed = verror.NewID("AcceptFailed")
errCacheClosed = verror.NewID("CacheClosed")
errConnKilledToFreeResources = verror.NewID("ConnKilledToFreeResources")
errInvalidProxyResponse = verror.NewID("InvalidProxyResponse")
errListeningWithNullRid = verror.NewID("ListeningWithNullRid")
errProxyResponse = verror.NewID("ProxyResponse")
errNoBlessingsForPeer = verror.NewID("NoBlessingsForPeer")
errConnNotInCache = verror.NewID("ConnNotInCache")
}
6 changes: 4 additions & 2 deletions x/ref/runtime/internal/naming/namespace/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ import (
"v.io/v23/verror"
)

var (
var errNoServers verror.IDAction

func init() {
errNoServers = verror.NewIDAction("errNoServers", verror.NoRetry)
)
}

// resolveAgainstMountTable asks each server in e.Servers that might be a mounttable to resolve e.Name. The requests
// are parallelized by the client rpc code.
Expand Down
37 changes: 27 additions & 10 deletions x/ref/runtime/internal/rpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,38 @@ const (
)

var (
errClientCloseAlreadyCalled = verror.NewID("errCloseAlreadyCalled")
errClientCloseAlreadyCalled verror.IDAction
errClientFinishAlreadyCalled verror.IDAction
errRequestEncoding verror.IDAction
errArgEncoding verror.IDAction
errResponseDecoding verror.IDAction
errResultDecoding verror.IDAction
errRemainingStreamResults verror.IDAction
errPeerAuthorizeFailed verror.IDAction
errTypeFlowFailure verror.IDAction

// These were originally defined in vdl and hence the same IDs that
// vdl would generate must be used here to ensure backwards compatibility.
errBadNumInputArgs verror.IDAction
errBadInputArg verror.IDAction
)

func init() {
errClientCloseAlreadyCalled = verror.NewID("errCloseAlreadyCalled")
errClientFinishAlreadyCalled = verror.NewID("errFinishAlreadyCalled")
errRequestEncoding = verror.NewID("errRequestEncoding")
errArgEncoding = verror.NewID("errArgEncoding")
errResponseDecoding = verror.NewID("errResponseDecoding")
errResultDecoding = verror.NewID("errResultDecoding")
errRemainingStreamResults = verror.NewID("errRemaingStreamResults")
errPeerAuthorizeFailed = verror.NewID("errPeerAuthorizedFailed")
errTypeFlowFailure = verror.NewID("errTypeFlowFailure")
errRequestEncoding = verror.NewID("errRequestEncoding")
errArgEncoding = verror.NewID("errArgEncoding")
errResponseDecoding = verror.NewID("errResponseDecoding")
errResultDecoding = verror.NewID("errResultDecoding")
errRemainingStreamResults = verror.NewID("errRemaingStreamResults")
errPeerAuthorizeFailed = verror.NewID("errPeerAuthorizedFailed")
errTypeFlowFailure = verror.NewID("errTypeFlowFailure")

// These were originally defined in vdl and hence the same IDs that
// vdl would generate must be used here to ensure backwards compatibility.
errBadNumInputArgs = verror.NewID("badNumInputArgs")
errBadInputArg = verror.NewID("badInputArg")
)
errBadInputArg = verror.NewID("badInputArg")
}

func preferNonTimeout(curr, prev error) error {
if prev != nil && errors.Is(curr, verror.ErrTimeout) {
Expand Down
6 changes: 5 additions & 1 deletion x/ref/runtime/internal/rpc/sort_endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@ import (
)

var (
errNoCompatibleServers = verror.NewID("errNoComaptibleServers")
errNoCompatibleServers verror.IDAction
defaultPreferredProtocolOrder = mkProtocolRankMap([]string{"unixfd", "wsh", "tcp4", "tcp", "*"})
)

func init() {
errNoCompatibleServers = verror.NewID("errNoComaptibleServers")
}

type serverLocality int

const (
Expand Down
6 changes: 5 additions & 1 deletion x/ref/runtime/internal/rpc/test/retry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ import (
"v.io/x/ref/test"
)

var errRetryThis = verror.NewIDAction("retry_test.retryThis", verror.RetryBackoff)
var errRetryThis verror.IDAction

func init() {
errRetryThis = verror.NewIDAction("retry_test.retryThis", verror.RetryBackoff)
}

type retryServer struct {
called int // number of times TryAgain has been called
Expand Down

0 comments on commit d7b0469

Please sign in to comment.