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:
parent
893671fa2b
commit
0bd4af89c9
1 changed files with 17 additions and 11 deletions
28
js/serial.js
28
js/serial.js
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue