Skip to content

Commit 799e311

Browse files
committed
Connection error handling
1 parent 7ab0afe commit 799e311

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

css/spbrowser.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ div#controls LABEL {
8686
#param_wthres {
8787
}
8888

89+
div#errors {
90+
height: 50px;
91+
width: 100px;
92+
background: #fa0000;
93+
}
94+
8995
div#graph-layout {
9096
height: 500px;
9197
background: #fafafa;

index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ <h1>SocioPatterns data browser</h1>
3232
<div><label>Threshold:</label><input id="param_wthres" name="param_wthres" type="text" /></div>
3333
</div>
3434
</div>
35+
36+
<div id="errors">&nbsp;
37+
</div>
38+
3539
<div id="graph-layout">
3640
</div>
3741

spbrowser-redis.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@ SPbrowser = function () {
2626

2727
},
2828
error: function(x, status, error){
29-
alert("Error: "+x.status+"\nStatus: "+status+"\nError: "+error)
29+
// console.debug("Error: "+x.status+"\nStatus: "+status+"\nError: "+error)
30+
if (x.status == 0) {
31+
message = "Error connecting to database";
32+
} else {
33+
message = "Error: "+x.status+"\nStatus: "+status+"\nError: "+error
34+
}
35+
$("#errors").text(message)
3036
}
3137
});
3238

@@ -136,6 +142,15 @@ SPbrowser = function () {
136142
}
137143

138144
callback(num_nodes_series);
145+
},
146+
error: function(x, status, error){
147+
// console.debug("Error: "+x.status+"\nStatus: "+status+"\nError: "+error)
148+
if (x.status == 0) {
149+
message = "Error connecting to database";
150+
} else {
151+
message = "Error: "+x.status+"\nStatus: "+status+"\nError: "+error
152+
}
153+
$("#errors").text(message)
139154
}
140155
});
141156
}
@@ -153,7 +168,13 @@ SPbrowser = function () {
153168
TIMESTAMP_MAX = param_t2;
154169
},
155170
error: function(x, status, error) {
156-
alert("Error: "+x.status+"\nStatus: "+status+"\n"+error);
171+
// console.debug("Error: "+x.status+"\nStatus: "+status+"\n"+error);
172+
if (x.status == 0) {
173+
message = "Error connecting to database";
174+
} else {
175+
message = "Error: "+x.status+"\nStatus: "+status+"\nError: "+error
176+
}
177+
$("#errors").text(message)
157178
}
158179
});
159180

0 commit comments

Comments
 (0)