Aufgrund einer Wartung wird GitLab am 18.01. zwischen 8:00 und 9:00 Uhr kurzzeitig nicht zur Verfügung stehen. / Due to maintenance, GitLab will be temporarily unavailable on 18.01. between 8:00 and 9:00 am.

Commit 67f5bdd3 authored by Marcel Rieger's avatar Marcel Rieger
Browse files

Forward kwargs from raise_ajax to AjaxException init.

parent 687b8e89
......@@ -36,16 +36,18 @@ class AjaxException(Exception):
self.alert = alert
def raise_ajax(fn):
def raise_ajax(fn=None, **kwargs):
"""
Decorator that transforms raised exceptions into AjaxExceptions.
"""
def wrapper(*args, **kwargs):
try:
return fn(*args, **kwargs)
except Exception as e:
if isinstance(e, AjaxException):
raise
else:
raise AjaxException(str(e))
return wrapper
def decorator(fn):
def wrapper(*args, **_kwargs):
try:
return fn(*args, **_kwargs)
except Exception as e:
if isinstance(e, AjaxException):
raise
else:
raise AjaxException(str(e), **kwargs)
return wrapper
return decorator if fn is None else decorator(fn)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment