Merge "Increase usefulness of the retry component compile errors"
This commit is contained in:
@@ -110,8 +110,18 @@ class _Flattener(object):
|
|||||||
elif isinstance(item, task.BaseTask):
|
elif isinstance(item, task.BaseTask):
|
||||||
return self._flatten_task
|
return self._flatten_task
|
||||||
elif isinstance(item, retry.Retry):
|
elif isinstance(item, retry.Retry):
|
||||||
raise TypeError("Retry controller %s (%s) is used not as a flow "
|
if len(self._history) == 1:
|
||||||
"parameter" % (item, type(item)))
|
raise TypeError("Retry controller: %s (%s) must only be used"
|
||||||
|
" as a flow constructor parameter and not as a"
|
||||||
|
" root component" % (item, type(item)))
|
||||||
|
else:
|
||||||
|
# TODO(harlowja): we should raise this type error earlier
|
||||||
|
# instead of later since we should do this same check on add()
|
||||||
|
# calls, this makes the error more visible (instead of waiting
|
||||||
|
# until compile time).
|
||||||
|
raise TypeError("Retry controller: %s (%s) must only be used"
|
||||||
|
" as a flow constructor parameter and not as a"
|
||||||
|
" flow added component" % (item, type(item)))
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class PatternCompileTest(test.TestCase):
|
|||||||
|
|
||||||
def test_retry(self):
|
def test_retry(self):
|
||||||
r = retry.AlwaysRevert('r1')
|
r = retry.AlwaysRevert('r1')
|
||||||
msg_regex = "^Retry controller .* is used not as a flow parameter"
|
msg_regex = "^Retry controller: .* must only be used .*"
|
||||||
self.assertRaisesRegexp(TypeError, msg_regex,
|
self.assertRaisesRegexp(TypeError, msg_regex,
|
||||||
compiler.PatternCompiler().compile, r)
|
compiler.PatternCompiler().compile, r)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user