runtime/internal/flow/flowcontrol: Move errors to a vdl file.
Change-Id: I0ca6212590935139b97775d03d8a854ebb0c91a2
diff --git a/runtime/internal/flow/flowcontrol/errors.vdl b/runtime/internal/flow/flowcontrol/errors.vdl
new file mode 100644
index 0000000..ddcab17
--- /dev/null
+++ b/runtime/internal/flow/flowcontrol/errors.vdl
@@ -0,0 +1,15 @@
+// Copyright 2015 The Vanadium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package flowcontrol
+
+// These messages are constructed so as to avoid embedding a component/method name
+// and are thus more suitable for inclusion in other verrors.
+// This practice of omitting {1}{2} should be used throughout the flow implementations
+// since all of their errors are intended to be used as arguments to higher level errors.
+// TODO(suharshs,toddw): Allow skipping of {1}{2} in vdl generated errors.
+error (
+ ConcurrentRun() {"en": "Run called concurrently"}
+ WrongFlowController() {"en": "Release called for worker from different flow controller"}
+)
\ No newline at end of file
diff --git a/runtime/internal/flow/flowcontrol/errors.vdl.go b/runtime/internal/flow/flowcontrol/errors.vdl.go
new file mode 100644
index 0000000..5876a41
--- /dev/null
+++ b/runtime/internal/flow/flowcontrol/errors.vdl.go
@@ -0,0 +1,35 @@
+// Copyright 2015 The Vanadium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// This file was auto-generated by the vanadium vdl tool.
+// Source: errors.vdl
+
+package flowcontrol
+
+import (
+ // VDL system imports
+ "v.io/v23/context"
+ "v.io/v23/i18n"
+ "v.io/v23/verror"
+)
+
+var (
+ ErrConcurrentRun = verror.Register("v.io/x/ref/runtime/internal/flow/flowcontrol.ConcurrentRun", verror.NoRetry, "{1:}{2:} Run called concurrently")
+ ErrWrongFlowController = verror.Register("v.io/x/ref/runtime/internal/flow/flowcontrol.WrongFlowController", verror.NoRetry, "{1:}{2:} Release called for worker from different flow controller")
+)
+
+func init() {
+ i18n.Cat().SetWithBase(i18n.LangID("en"), i18n.MsgID(ErrConcurrentRun.ID), "{1:}{2:} Run called concurrently")
+ i18n.Cat().SetWithBase(i18n.LangID("en"), i18n.MsgID(ErrWrongFlowController.ID), "{1:}{2:} Release called for worker from different flow controller")
+}
+
+// NewErrConcurrentRun returns an error with the ErrConcurrentRun ID.
+func NewErrConcurrentRun(ctx *context.T) error {
+ return verror.New(ErrConcurrentRun, ctx)
+}
+
+// NewErrWrongFlowController returns an error with the ErrWrongFlowController ID.
+func NewErrWrongFlowController(ctx *context.T) error {
+ return verror.New(ErrWrongFlowController, ctx)
+}
diff --git a/runtime/internal/flow/flowcontrol/flowcontrol.go b/runtime/internal/flow/flowcontrol/flowcontrol.go
index f744641..2b6e64b 100644
--- a/runtime/internal/flow/flowcontrol/flowcontrol.go
+++ b/runtime/internal/flow/flowcontrol/flowcontrol.go
@@ -10,18 +10,8 @@
"sync"
"v.io/v23/context"
- "v.io/v23/verror"
)
-const pkgPath = "v.io/x/ref/runtime/internal/flow/flowcontrol"
-
-var ErrConcurrentRun = verror.Register(
- verror.ID(pkgPath+".ErrConcurrentRun"),
- verror.NoRetry, "Run called concurrently.")
-var ErrWrongFlowController = verror.Register(
- verror.ID(pkgPath+".ErrWrongFlowController"),
- verror.NoRetry, "Release called for worker from different flow controller.")
-
// Runners are called by Workers. For a given flow controller
// only one Runner will be running at a time. tokens specifies
// the number of tokens available for this call. Implementors
@@ -69,7 +59,7 @@
w.fc.mu.Lock()
if w.state != idle {
w.fc.mu.Unlock()
- return verror.New(ErrConcurrentRun, ctx)
+ return NewErrConcurrentRun(ctx)
}
w.state = running
@@ -227,7 +217,7 @@
fc.mu.Lock()
for _, t := range to {
if t.Worker.fc != fc {
- return verror.New(ErrWrongFlowController, ctx)
+ return NewErrWrongFlowController(ctx)
}
t.Worker.releaseLocked(ctx, t.Tokens)
}