chiark / gitweb /
crashing and msgs
[hippotat.git] / client
diff --git a/client b/client
index 48c4f3f..e6ea8ed 100755 (executable)
--- a/client
+++ b/client
@@ -145,13 +145,18 @@ def req_ok(req, resp):
 def req_err(req, err):
   # called when the Deferred fails, or (if it completes),
   # later, by ResponsConsumer or ErrorResponsConsumer
-  log_debug(DBG.HTTP_CTRL, 'req_err ' + str(err), idof=req)
-  if isinstance(err, twisted.python.failure.Failure):
-    err = err.getTraceback()
-  print(err, file=sys.stderr)
-  outstanding[req] = 'ERR'
-  log_outstanding()
-  reactor.callLater(c.http_retry, (lambda: req_fin(req)))
+  try:
+    log_debug(DBG.HTTP_CTRL, 'req_err ' + str(err), idof=req)
+    if isinstance(err, twisted.python.failure.Failure):
+      err = err.getTraceback()
+    print('[%#x] %s' % (id(req), err), file=sys.stderr)
+    if not isinstance(outstanding[req], int):
+      raise RuntimeError('[%#x] previously %s' % (id(req), outstanding[req]))
+    outstanding[req] = err
+    log_outstanding()
+    reactor.callLater(c.http_retry, (lambda: req_fin(req)))
+  except Exception as e:
+    crash(traceback.format_exc() + '\n----- handling -----\n' + err)
 
 def req_fin(req):
   del outstanding[req]