derived function below

This commit is contained in:
Jean-Paul Calderone 2020-09-18 14:50:45 -04:00
parent 8f3a32a22c
commit 97872118a5

View File

@ -203,19 +203,6 @@ def should_create_intermediate_directories(req):
return bool(req.method in ("PUT", "POST") and
t not in ("delete", "rename", "rename-form", "check"))
def humanize_failure(f):
"""
Create an human-oriented description of a failure along with some HTTP
metadata.
:param Failure f: The failure to describe.
:return (bytes, int): A tuple of some prose and an HTTP code describing
the failure.
"""
return humanize_exception(f.value)
def humanize_exception(exc):
"""
Like ``humanize_failure`` but for an exception.
@ -305,6 +292,19 @@ def humanize_exception(exc):
return (str(exc), None)
def humanize_failure(f):
"""
Create an human-oriented description of a failure along with some HTTP
metadata.
:param Failure f: The failure to describe.
:return (bytes, int): A tuple of some prose and an HTTP code describing
the failure.
"""
return humanize_exception(f.value)
class MyExceptionHandler(appserver.DefaultExceptionHandler, object):
def simple(self, ctx, text, code=http.BAD_REQUEST):
req = IRequest(ctx)