No need to catch exceptions here; they shouldn't occur

This commit is contained in:
Jim Paris 2019-08-14 18:55:01 -04:00
parent b574fc86f4
commit 640c1bc95e

View File

@ -126,13 +126,10 @@ def json_error_page(status, message, traceback, version,
"message" : message, "message" : message,
"traceback" : traceback } "traceback" : traceback }
# Don't send a traceback if the error was 400-499 (client's fault) # Don't send a traceback if the error was 400-499 (client's fault)
try: code = int(status.split()[0])
code = int(status.split()[0]) if not force_traceback:
if not force_traceback: if code >= 400 and code <= 499:
if code >= 400 and code <= 499: errordata["traceback"] = ""
errordata["traceback"] = ""
except Exception: # pragma: no cover
pass
# Override the response type, which was previously set to text/html # Override the response type, which was previously set to text/html
cherrypy.serving.response.headers['Content-Type'] = ( cherrypy.serving.response.headers['Content-Type'] = (
"application/json;charset=utf-8" ) "application/json;charset=utf-8" )