From 46a44572334a08a3037c95608bc4ea6f9afa2114 Mon Sep 17 00:00:00 2001 From: Max Goodman Date: Wed, 10 Apr 2013 17:12:57 -0700 Subject: [PATCH] Explicitly set errors in VJSON, with error codes. --- r2/r2/lib/validator/validator.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/r2/r2/lib/validator/validator.py b/r2/r2/lib/validator/validator.py index 86db69452..1309386e6 100644 --- a/r2/r2/lib/validator/validator.py +++ b/r2/r2/lib/validator/validator.py @@ -2168,18 +2168,15 @@ class VPermissions(Validator): return type, perm_set -class VJSON(VRequired): - def __init__(self, item, *args, **kwargs): - VRequired.__init__(self, item, errors.BAD_JSON, *args, **kwargs) - +class VJSON(Validator): def run(self, json_str): if not json_str: - return self.error() + return self.set_error('BAD_JSON', code=400) else: try: return json.loads(json_str) except ValueError: - return self.error() + return self.set_error('BAD_JSON', code=400) def param_docs(self): return {