[tor-commits] [flashproxy/master] Better connection failure diagnostics.
dcf at torproject.org
dcf at torproject.org
Mon Apr 9 04:08:42 UTC 2012
commit bc95aca58e2f615f2fb2d014d422e6e1d78087f1
Author: David Fifield <david at bamsoftware.com>
Date: Tue Mar 13 10:45:33 2012 -0700
Better connection failure diagnostics.
---
flashproxy.js | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/flashproxy.js b/flashproxy.js
index 05674c4..e7d60c8 100644
--- a/flashproxy.js
+++ b/flashproxy.js
@@ -128,7 +128,17 @@ function FlashProxy()
fac_url = "http://" + encodeURIComponent(fac_addr.host)
+ ":" + encodeURIComponent(fac_addr.port) + "/";
xhr = new XMLHttpRequest();
- xhr.open("GET", fac_url);
+ try {
+ xhr.open("GET", fac_url);
+ } catch (err) {
+ /* An exception happens here when, for example, NoScript allows the
+ domain on which the proxy badge runs, but not the domain to which
+ it's trying to make the HTTP request. The exception message is
+ like "Component returned failure code: 0x805e0006
+ [nsIXMLHttpRequest.open]" on Firefox. */
+ this.puts("Facilitator: exception while connecting: " + repr(err.message) + ".");
+ return;
+ }
xhr.responseType = "text";
xhr.onreadystatechange = function() {
/* Status 0 is UNSENT. 4 is DONE. */
@@ -137,10 +147,8 @@ function FlashProxy()
} else if (xhr.readyState == 4) {
if (xhr.status == 200)
this.fac_complete(xhr.responseText);
- else if (xhr.readyState == 4)
- this.puts("Facilitator: got status " + xhr.status + ".");
else
- this.puts("Facilitator: unknown error.");
+ this.puts("Facilitator: can't connect: got response code " + xhr.status + ".");
}
}.bind(this);
this.puts("Facilitator: connecting to " + fac_url + ".");
More information about the tor-commits
mailing list