From 672c44009127987b9653db5a2bb7bac4182d3c2f Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Tue, 3 Nov 2020 10:40:41 -0500 Subject: [PATCH] Better error reporting. --- src/allmydata/test/common_web.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/allmydata/test/common_web.py b/src/allmydata/test/common_web.py index 033b77c98..a6278810b 100644 --- a/src/allmydata/test/common_web.py +++ b/src/allmydata/test/common_web.py @@ -1,3 +1,4 @@ +from six import ensure_str __all__ = [ "do_http", @@ -36,6 +37,14 @@ from ..webish import ( TahoeLAFSRequest, ) + +class VerboseError(Error): + """Include the HTTP body response too.""" + + def __str__(self): + return Error.__str__(self) + " " + ensure_str(self.response) + + @inlineCallbacks def do_http(method, url, **kwargs): response = yield treq.request(method, url, persistent=False, **kwargs) @@ -43,7 +52,7 @@ def do_http(method, url, **kwargs): # TODO: replace this with response.fail_for_status when # https://github.com/twisted/treq/pull/159 has landed if 400 <= response.code < 600: - raise Error(response.code, response=body) + raise VerboseError(response.code, response=body) returnValue(body)