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
67f5bdd3
Commit
67f5bdd3
authored
May 22, 2015
by
Marcel Rieger
Browse files
Forward kwargs from raise_ajax to AjaxException init.
parent
687b8e89
Changes
1
Hide whitespace changes
Inline
Side-by-side
vispa/remote/__init__.py
View file @
67f5bdd3
...
...
@@ -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
)
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