Legoktm has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/399761 )

Change subject: Provide some debugging information when unable to contact hound
......................................................................


Provide some debugging information when unable to contact hound

Bug: T183443
Change-Id: I68181211755215407892631f2c39e6b299d5a989
---
M app.py
1 file changed, 15 insertions(+), 4 deletions(-)

Approvals:
  Legoktm: Verified; Looks good to me, approved



diff --git a/app.py b/app.py
index 1e595b9..542f238 100644
--- a/app.py
+++ b/app.py
@@ -20,6 +20,7 @@
 from flask import Flask, Response, request, redirect, url_for
 
 import requests
+import traceback
 
 app = Flask(__name__)
 
@@ -93,10 +94,20 @@
     if backend not in BACKENDS:
         return 'invalid backend'
     port = BACKENDS[backend]
-    r = requests.get(
-        'http://localhost:%s/%s' % (port, path),
-        params=request.args
-    )
+    try:
+        r = requests.get(
+            'http://localhost:%s/%s' % (port, path),
+            params=request.args
+        )
+    except requests.exceptions.ConnectionError as e:
+        resp = """
+Unable to contact hound. Please retry in a few minutes.
+If this error continues, please report it in Phabricator
+with the following information:
+
+"""
+        resp += traceback.format_exc()
+        return Response(resp, 503, mimetype='text/plain')
     excluded_headers = ['content-encoding', 'content-length', 
'transfer-encoding', 'connection']
     headers = [(name, value) for (name, value) in r.raw.headers.items()
                if name.lower() not in excluded_headers]

-- 
To view, visit https://gerrit.wikimedia.org/r/399761
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I68181211755215407892631f2c39e6b299d5a989
Gerrit-PatchSet: 1
Gerrit-Project: labs/codesearch
Gerrit-Branch: master
Gerrit-Owner: Legoktm <lego...@member.fsf.org>
Gerrit-Reviewer: Legoktm <lego...@member.fsf.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to