From 0b248905e5b3b3787c426989f2c41bed4b50d70a Mon Sep 17 00:00:00 2001 From: Omer Katz Date: Wed, 31 Jul 2019 12:07:41 +0300 Subject: [PATCH] Added a flag which indicates whether the action failed. --- eliot/_action.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/eliot/_action.py b/eliot/_action.py index 07312e4..c1bc154 100644 --- a/eliot/_action.py +++ b/eliot/_action.py @@ -221,6 +221,7 @@ def __init__(self, logger, task_uuid, task_level, action_type, serializers=None) } self._serializers = serializers self._finished = False + self._failed = False @property def task_uuid(self): @@ -228,6 +229,13 @@ def task_uuid(self): @return str: the current action's task UUID. """ return self._identification[TASK_UUID_FIELD] + + @property + def failed(self): + """ + @return bool: indicates whether during the action an exception was raised. + """ + return self._failed def serialize_task_id(self): """ @@ -327,6 +335,7 @@ def finish(self, exception=None): if self._serializers is not None: serializer = self._serializers.success else: + self._failed = True fields = _error_extraction.get_fields_for_exception(self._logger, exception) fields[EXCEPTION_FIELD] = "%s.%s" % ( exception.__class__.__module__,