Skip to content

Commit

Permalink
Better error handling, but not perfect.
Browse files Browse the repository at this point in the history
  • Loading branch information
mmosca committed Feb 13, 2025
1 parent c352133 commit 1e220cd
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions js/ublox/UBLOX.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,29 +157,37 @@ var ublox = (function () {
if(req.status == 200) {
successCallback(req.response);
} else {
failCallback(event);
if(failCallback != null) {
var dec = new TextDecoder('utf-8');
GUI.log(`http status: ${req.status}: ${dec.decode(req.response)}`)
failCallback(req.response);
}
}
};
}

if (failCallback != null) {
req.onerror = (event) => {
failCallback(event);
var dec = new TextDecoder('utf-8');
GUI.log(i18n.getMessage("gpsAssistnowLoadDataError") + ": Received an unkonwn error when trying to download data.")
failCallback("Unknown error.");
}
}

try {
req.send(null);
} catch(error) {
GUI.alert(i18n.getMessage("gpsAssistnowLoadDataError"));
console.log(i18n.getMessage("gpsAssistnowLoadDataError") + ':' + error.toString());
GUI.log(i18n.getMessage("gpsAssistnowLoadDataError") + ':' + error.toString());
console.log(i18n.getMessage("gpsAssistnowLoadDataError") + ':' + JSON.stringify(error));
}
}


function loadError(e) {
GUI.alert(i18n.getMessage("gpsAssistnowLoadDataError"));
GUI.log('response error: ' + e.currentTarget.response);
var dec = new TextDecoder('utf-8');
GUI.log(JSON.stringify(e));
}

// For more info on assistnow, check:
Expand Down

0 comments on commit 1e220cd

Please sign in to comment.