summaryrefslogtreecommitdiffstats
path: root/module/web/api_app.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-01-02 22:03:02 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-01-02 22:03:02 +0100
commita786fef06639da439f9edd367db36388dc1c2658 (patch)
tree84b7d7acf23c300bef4b0fd5ee744e408ffc1152 /module/web/api_app.py
parentNew naming: pyLoadCore -> pyload (diff)
downloadpyload-a786fef06639da439f9edd367db36388dc1c2658.tar.xz
little cleanup, improved handling of custom exceptions via api
Diffstat (limited to 'module/web/api_app.py')
-rw-r--r--module/web/api_app.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/module/web/api_app.py b/module/web/api_app.py
index 4a84c85ca..ff8d0134c 100644
--- a/module/web/api_app.py
+++ b/module/web/api_app.py
@@ -10,6 +10,7 @@ from bottle import route, request, response, HTTPError
from utils import set_session, get_user_api
from webinterface import PYLOAD
+from module.Api import ExceptionObject
from module.remote.json_converter import loads, dumps
from module.utils import remove_chars
@@ -46,11 +47,13 @@ def call_api(func, args=""):
try:
return callApi(func, *args, **kwargs)
+ except ExceptionObject, e:
+ return HTTPError(400, dumps(e))
except Exception, e:
print_exc()
return HTTPError(500, dumps({"error": e.message, "traceback": format_exc()}))
-# Better error codes on invalid input
+# TODO Better error codes on invalid input
def callApi(func, *args, **kwargs):
if not hasattr(PYLOAD.EXTERNAL, func) or func.startswith("_"):