[Twisted-Python] ANN: Eliot 1.7, the causal logging library, now with inlineCallbacks support
Itamar Turner-Trauring
itamar at itamarst.org
Mon Mar 25 11:23:19 MDT 2019
> Interesting library.
>
> It seems that I cannot have a action finish with an error unless I raise an
> exception. That seems limiting, there are lots of cases where I have code
> that hits an error condition and does not raise an exception. For example
> an HTTP request that gets a non 200 status.
>
> Have I missed something?
You don't have to raise an exception, though the current API requires you to create an exception instance:
---
from eliot import start_action
action = start_action(action_type="http_request"):
with action.context():
response = http_request()
if response.code == 200:
action.finish()
return response.json
else:
action.finish(HTTPError(code=response.code))
return None
---
The Twisted APIs for Eliot likewise support Deferreds using a DeferredContext object, again with no need to raise an exception:
https://eliot.readthedocs.io/en/stable/generating/twisted.html#actions-and-deferreds
-Itamar
More information about the Twisted-Python
mailing list