Add a "passthrough" parameter for calls through the safetymetaclass

So errors don’t get caught
This commit is contained in:
mathieui 2019-08-23 12:31:20 +02:00 committed by Maxime “pep” Buquet
parent 33a1519a39
commit 5a1a2e6c18
2 changed files with 8 additions and 2 deletions

View file

@ -75,9 +75,12 @@ class SafetyMetaclass(type):
@staticmethod
def safe_func(f):
def helper(*args, **kwargs):
passthrough = kwargs.pop('passthrough', False)
try:
return f(*args, **kwargs)
except:
if passthrough:
raise
if inspect.stack()[1][1] == inspect.getfile(f):
raise
elif SafetyMetaclass.core:
@ -86,9 +89,12 @@ class SafetyMetaclass(type):
'Error')
return None
async def async_helper(*args, **kwargs):
passthrough = kwargs.pop('passthrough', False)
try:
return await f(*args, **kwargs)
except:
if passthrough:
raise
if inspect.stack()[1][1] == inspect.getfile(f):
raise
elif SafetyMetaclass.core:

View file

@ -245,9 +245,9 @@ class E2EEPlugin(BasePlugin):
# Call the enabled encrypt method
func = self._enabled_tabs[jid]
if iscoroutinefunction(func):
await func(message, tab)
await func(message, tab, passthrough=True)
else:
func(message, tab)
func(message, tab, passthrough=True)
if has_body:
# Only add EME tag if the message has a body.