aboutsummaryrefslogtreecommitdiffstats
path: root/src/rest/parsers.py
diff options
context:
space:
mode:
authorTom Christie2011-01-17 17:34:58 +0000
committerTom Christie2011-01-17 17:34:58 +0000
commit99799032721a32220c32d4a74a950bdd07b13cb3 (patch)
tree8da016ed257181ba21804c947f18bde771476b08 /src/rest/parsers.py
parentb0ce3f92c68b13d7f437a21bedcc95727e271860 (diff)
downloaddjango-rest-framework-99799032721a32220c32d4a74a950bdd07b13cb3.tar.bz2
Mostly improving documentation
Diffstat (limited to 'src/rest/parsers.py')
-rw-r--r--src/rest/parsers.py6
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