Add error handling on bad schedule access

This commit is contained in:
nemunaire 2018-06-06 22:06:11 +02:00
parent 7d05a79ab3
commit efe6250f38
2 changed files with 10 additions and 1 deletions

10
app.js
View File

@ -112,7 +112,14 @@ function getSchedule(type, code, station, way) {
nextSchedule = setTimeout(function() {
getSchedule(type, code, station, way);
}, 15000);
});
})
.fail(function(data) {
if (data.responseJSON && data.responseJSON.result && data.responseJSON.result.message)
{
$("#mainerror").text(data.responseJSON.result.message);
$("#mainerror").show();
}
});
}
function defineTag(type, station) {
@ -142,6 +149,7 @@ function main(uri, fetchTrafic) {
$("#stations").attr("disabled", true);
$("#schedule").hide();
$("#loading").hide();
$("#mainerror").hide();
if (nextTraffic != null) {
clearTimeout(nextTraffic);

View File

@ -8,6 +8,7 @@
</head>
<body class="container">
<h1 id="loading">Chargement en cours &hellip;</h1>
<h1 id="mainerror" style="display: none; color: red"></h1>
<form id="lines" style="display: none">