aboutsummaryrefslogtreecommitdiff
path: root/store.py
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2018-04-04 12:02:50 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2018-04-04 12:50:34 +0200
commitd8e233ac11edac1481f0315e25f79b0390c45e29 (patch)
tree6872b4a8f25e276cbc8877a2de9c1caead5a2d81 /store.py
parent90d7423eec074a0ed0af680c223180f8d7e1d4e6 (diff)
downloadTrader-d8e233ac11edac1481f0315e25f79b0390c45e29.tar.gz
Trader-d8e233ac11edac1481f0315e25f79b0390c45e29.tar.zst
Trader-d8e233ac11edac1481f0315e25f79b0390c45e29.zip
Log http requests exceptions
Diffstat (limited to 'store.py')
-rw-r--r--store.py31
1 files changed, 22 insertions, 9 deletions
diff --git a/store.py b/store.py
index 2b5c18a..3f3718f 100644
--- a/store.py
+++ b/store.py
@@ -176,15 +176,28 @@ class ReportStore:
176 }) 176 })
177 177
178 def log_http_request(self, method, url, body, headers, response): 178 def log_http_request(self, method, url, body, headers, response):
179 self.add_log({ 179 if isinstance(response, Exception):
180 "type": "http_request", 180 self.add_log({
181 "method": method, 181 "type": "http_request",
182 "url": url, 182 "method": method,
183 "body": body, 183 "url": url,
184 "headers": headers, 184 "body": body,
185 "status": response.status_code, 185 "headers": headers,
186 "response": response.text 186 "status": -1,
187 }) 187 "response": None,
188 "error": response.__class__.__name__,
189 "error_message": str(response),
190 })
191 else:
192 self.add_log({
193 "type": "http_request",
194 "method": method,
195 "url": url,
196 "body": body,
197 "headers": headers,
198 "status": response.status_code,
199 "response": response.text
200 })
188 201
189 def log_error(self, action, message=None, exception=None): 202 def log_error(self, action, message=None, exception=None):
190 self.print_log("[Error] {}".format(action)) 203 self.print_log("[Error] {}".format(action))