From 7ca5f168e45c387160628fd41176507ec741dbe4 Mon Sep 17 00:00:00 2001 From: Renat Akhmerov Date: Wed, 15 Jul 2015 18:24:51 +0600 Subject: [PATCH] Error result: doc explaining error result in base action class Change-Id: I59da6788f2df46ee3346957832bc0082dfbccd7c --- mistral/actions/base.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/mistral/actions/base.py b/mistral/actions/base.py index 7d053538..73275ca4 100644 --- a/mistral/actions/base.py +++ b/mistral/actions/base.py @@ -47,12 +47,21 @@ class Action(object): def run(self): """Run action logic. - :return: result of the action. Note that for asynchronous actions + :return: Result of the action. Note that for asynchronous actions it should always be None, however, if even it's not None it will be ignored by a caller. - In case if action failed this method must throw a ActionException - to indicate that. + Result can be of two types: + 1) Any serializable value meaningful from a user perspective (such + as string, number or dict). + 2) Instance of {mistral.workflow.utils.Result} which has field "data" + for success result and field "error" for keeping so called "error + result" like HTTP error code and similar. Using the second type + allows to communicate a result even in case of error and hence to have + conditions in "on-error" clause of direct workflows. Depending on + particular action semantics one or another option may be preferable. + In case if action failed and there's no need to communicate any error + result this method should throw a ActionException. """ pass