From 085c68b5a7058655e311400a20ffcd51248fbbfc Mon Sep 17 00:00:00 2001 From: Michael Jurke Date: Fri, 13 Nov 2015 17:28:56 +0100 Subject: [PATCH] dumps schematics errors as valid json --- supercell/requesthandler.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/supercell/requesthandler.py b/supercell/requesthandler.py index 686d472..832c2bc 100644 --- a/supercell/requesthandler.py +++ b/supercell/requesthandler.py @@ -24,6 +24,7 @@ import time from schematics.models import Model +from schematics.exceptions import BaseError from tornado import gen, iostream from tornado.concurrent import is_future from tornado.escape import to_unicode @@ -136,6 +137,8 @@ def _check_consumer(self): except NoConsumerFound: # TODO return available consumer types?! raise HTTPError(406) + except BaseError as e: + raise HTTPError(400, reason=json.dumps(e.messages)) except Exception as e: raise HTTPError(400, reason=text_type(e))