1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-18 13:55:18 +03:00

catch lastError cleanly in current context

This commit is contained in:
cTn 2014-09-01 14:56:13 +02:00
parent 893671fa2b
commit 0bd4af89c9

View file

@ -30,18 +30,24 @@ var serial = {
switch (info.error) { switch (info.error) {
case 'system_error': // we might be able to recover from this one case 'system_error': // we might be able to recover from this one
var crunch_status = function (info) { var crunch_status = function (info) {
if (info && !info.paused) { if (info) {
console.log('SERIAL: Connection recovered from last onReceiveError'); if (!info.paused) {
googleAnalytics.sendException('Serial: onReceiveError - recovered', false); console.log('SERIAL: Connection recovered from last onReceiveError');
} else { googleAnalytics.sendException('Serial: onReceiveError - recovered', false);
console.log('SERIAL: Connection did not recover from last onReceiveError, disconnecting');
GUI.log('Unrecoverable <span style="color: red">failure</span> of serial connection, disconnecting...');
googleAnalytics.sendException('Serial: onReceiveError - unrecoverable', false);
if (GUI.connected_to || GUI.connecting_to) {
$('a.connect').click();
} else { } else {
self.disconnect(); console.log('SERIAL: Connection did not recover from last onReceiveError, disconnecting');
GUI.log('Unrecoverable <span style="color: red">failure</span> of serial connection, disconnecting...');
googleAnalytics.sendException('Serial: onReceiveError - unrecoverable', false);
if (GUI.connected_to || GUI.connecting_to) {
$('a.connect').click();
} else {
self.disconnect();
}
}
} else {
if (chrome.runtime.lastError) {
console.error(chrome.runtime.lastError.message);
} }
} }
} }