mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-29 00:38:11 -05:00
Rename BAD_JSON -> JSON_PARSE_ERROR.
I intend to prefix JSON related errors with 'JSON'.
This commit is contained in:
@@ -128,7 +128,7 @@ error_list = dict((
|
||||
('MULTI_CANNOT_EDIT', _('you can\'t change that multireddit')),
|
||||
('MULTI_TOO_MANY_SUBREDDITS', _('no more space for subreddits in that multireddit')),
|
||||
('MULTI_SPECIAL_SUBREDDIT', _("can't add special subreddit %(path)s")),
|
||||
('BAD_JSON', _('unable to parse JSON data')),
|
||||
('JSON_PARSE_ERROR', _('unable to parse JSON data')),
|
||||
))
|
||||
|
||||
errors = Storage([(e, e) for e in error_list.keys()])
|
||||
|
||||
@@ -2183,12 +2183,12 @@ class VPermissions(Validator):
|
||||
class VJSON(Validator):
|
||||
def run(self, json_str):
|
||||
if not json_str:
|
||||
return self.set_error('BAD_JSON', code=400)
|
||||
return self.set_error('JSON_PARSE_ERROR', code=400)
|
||||
else:
|
||||
try:
|
||||
return json.loads(json_str)
|
||||
except ValueError:
|
||||
return self.set_error('BAD_JSON', code=400)
|
||||
return self.set_error('JSON_PARSE_ERROR', code=400)
|
||||
|
||||
def param_docs(self):
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user