Skip to content

Commit b3e3d18

Browse files
committed
Catch the error and console log
1 parent cbf9418 commit b3e3d18

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/core/Board.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@
3030
DISCONNECT: 'disconnect'
3131
};
3232

33-
// Message command bytes (128-255/0x80-0xFF)
33+
/**
34+
* Message command bytes (128-255/0x80-0xFF)
35+
* https://github.com/firmata/protocol/blob/master/protocol.md
36+
*/
3437
var DIGITAL_MESSAGE = 0x90,
3538
ANALOG_MESSAGE = 0xE0,
3639
REPORT_ANALOG = 0xC0,
@@ -122,14 +125,19 @@
122125
}
123126

124127
function onMessage(data) {
125-
var len = data.length;
128+
try {
129+
var len = data.length;
126130

127-
if (len) {
128-
for (var i = 0; i < len; i++) {
129-
this.processInput(data[i]);
131+
if (len) {
132+
for (var i = 0; i < len; i++) {
133+
this.processInput(data[i]);
134+
}
135+
} else {
136+
this.processInput(data);
130137
}
131-
} else {
132-
this.processInput(data);
138+
} catch (err) {
139+
console.error(err);
140+
throw err;
133141
}
134142
}
135143

0 commit comments

Comments
 (0)