diff options
Diffstat (limited to 'src/rest/parsers.py')
| -rw-r--r-- | src/rest/parsers.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/rest/parsers.py b/src/rest/parsers.py index 73073243..ac449e49 100644 --- a/src/rest/parsers.py +++ b/src/rest/parsers.py @@ -1,4 +1,5 @@ import json +from rest.status import ResourceException, Status class BaseParser(object): def __init__(self, resource): @@ -10,7 +11,10 @@ class BaseParser(object): class JSONParser(BaseParser): def parse(self, input): - return json.loads(input) + try: + return json.loads(input) + except ValueError, exc: + raise ResourceException(Status.HTTP_400_BAD_REQUEST, {'detail': 'JSON parse error - %s' % str(exc)}) class XMLParser(BaseParser): pass |
