summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjmoenig <jens@moenig.org>2013-03-22 12:07:54 +0100
committerjmoenig <jens@moenig.org>2013-03-22 12:07:54 +0100
commitf34d319b0c9f7b1c2db8abb1737e278fbac363e3 (patch)
tree929d4cd07617ad736c76c97c8271d997757b552d
parent2c54645400bb6afe6ae4dea1f714dabc8c886708 (diff)
downloadsnap-byow-f34d319b0c9f7b1c2db8abb1737e278fbac363e3.tar.gz
snap-byow-f34d319b0c9f7b1c2db8abb1737e278fbac363e3.zip
Cloud: Dynamic fallback msg support
before popping up an error dialog, the GUI can check another URL for an explanation about server downtimes etc.,
-rw-r--r--gui.js25
-rwxr-xr-xhistory.txt3
2 files changed, 26 insertions, 2 deletions
diff --git a/gui.js b/gui.js
index 4ecb643..b5fcd2b 100644
--- a/gui.js
+++ b/gui.js
@@ -3180,8 +3180,31 @@ IDE_Morph.prototype.cloudResponse = function () {
IDE_Morph.prototype.cloudError = function () {
var myself = this;
+
+ function getURL(url) {
+ try {
+ var request = new XMLHttpRequest();
+ request.open('GET', url, false);
+ request.send();
+ if (request.status === 200) {
+ return request.responseText;
+ }
+ return null;
+ } catch (err) {
+ return null;
+ }
+ }
+
return function (responseText, url) {
- var response = responseText;
+ // first, try to find out an explanation for the error
+ // and notify the user about it,
+ // if none is found, show an error dialog box
+ var response = responseText,
+ explanation = getURL('http://snap.berkeley.edu/cloudmsg.txt');
+ if (explanation) {
+ myself.showMessage(explanation);
+ return;
+ }
if (response.length > 50) {
response = response.substring(0, 50) + '...';
}
diff --git a/history.txt b/history.txt
index ef221fd..b3445c4 100755
--- a/history.txt
+++ b/history.txt
@@ -1557,4 +1557,5 @@ ______
* Blocks, GUI: "Zoom blocks…" feature in the settings menu (no longer hidden)
* Objects: numeric prompters for watcher's sliderMin/Max
* translation updates
-* Objects: 'pic...' screenshot feature for the stage \ No newline at end of file
+* Objects: 'pic…' screenshot feature for the stage
+* GUI, Cloud: Fallback message support before showing an error \ No newline at end of file