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
1 changed files with 4 additions and 1 deletions

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)])