Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
3pia
VISPA
VISPA web
Commits
687b8e89
Commit
687b8e89
authored
May 22, 2015
by
Marcel Rieger
Browse files
Add raise_ajax decorator to vispa.remote.
parent
e7d5c234
Changes
1
Hide whitespace changes
Inline
Side-by-side
vispa/remote/__init__.py
View file @
687b8e89
...
...
@@ -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
):
try
:
return
fn
(
*
args
,
**
kwargs
)
except
Exception
as
e
:
if
isinstance
(
e
,
AjaxException
):
raise
else
:
raise
AjaxException
(
str
(
e
))
return
wrapper
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment