From a786fef06639da439f9edd367db36388dc1c2658 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Wed, 2 Jan 2013 22:03:02 +0100 Subject: little cleanup, improved handling of custom exceptions via api --- module/web/api_app.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'module/web') 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("_"): -- cgit v1.2.3