统一错误处理

This commit is contained in:
virusdefender 2016-10-04 13:03:54 +08:00
parent d2e4e44d42
commit 28851ee4ca

View File

@ -124,12 +124,18 @@ class JudgeServer(object):
else:
return json.dumps({"err": "InvalidMethod", "data": None})
return json.dumps({"err": None, "data": callback(**data)})
except Exception as e:
except (CompileError, TokenVerificationFailed, SPJCompileError, JudgeClientError) as e:
logging.exception(e)
ret = dict()
ret["err"] = e.__class__.__name__
ret["data"] = e.message
return json.dumps(ret)
except Exception as e:
logging.exception(e)
ret = dict()
ret["err"] = "JudgeClientError"
ret["data"] =e.__class__.__name__ + ":" + e.message
return json.dumps(ret)
urls = (