Catch all the exceptions in a plugin action wrapper.

The @action decorator should capture all the exceptions,
log them and return them on `Response.errors`.

This ensures that uncaught exceptions from plugin
actions won't unwind out of control, and also that they
are logged and treated consistently across all the
integrations.
This commit is contained in:
Fabio Manganiello 2023-09-14 23:08:23 +02:00
parent ac72b2f7a8
commit 2c93049ee5
Signed by: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -32,7 +32,10 @@ def action(f: Callable[..., Any]) -> Callable[..., Response]:
response = Response()
try:
result = f(*args, **kwargs)
except TypeError as e:
except Exception as e:
if isinstance(e, KeyboardInterrupt):
return response
_logger.exception(e)
result = Response(errors=[str(e)])