diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-01-02 22:03:02 +0100 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-01-02 22:03:02 +0100 |
commit | a786fef06639da439f9edd367db36388dc1c2658 (patch) | |
tree | 84b7d7acf23c300bef4b0fd5ee744e408ffc1152 /module/web/api_app.py | |
parent | New naming: pyLoadCore -> pyload (diff) | |
download | pyload-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.py | 5 |
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("_"): |