Commit 687b8e89 authored by Marcel Rieger's avatar Marcel Rieger
Browse files

Add raise_ajax decorator to vispa.remote.

parent e7d5c234
......@@ -34,3 +34,18 @@ class AjaxException(Exception):
self.code = code
self.alert = alert
def raise_ajax(fn):
Decorator that transforms raised exceptions into AjaxExceptions.
def wrapper(*args, **kwargs):
return fn(*args, **kwargs)
except Exception as e:
if isinstance(e, AjaxException):
raise AjaxException(str(e))
return wrapper
Supports Markdown
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