Skip to content

Commit 1b4c54b

Browse files
author
Daisuke Baba
committed
Improve error messages for debugging
1 parent 0eed34c commit 1b4c54b

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/generic-ble.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ function connectToPeripheral(peripheral, RED, forceConnect=false) {
499499
discoveryTimeout = null;
500500
onConnected = null;
501501
reject(`<${peripheral.uuid}> Discovery Timeout`);
502-
}, BLE_CONNECTION_TIMEOUT_MS);
502+
}, BLE_DISCOVERY_TIMEOUT_MS);
503503
peripheral._discovering = true;
504504
peripheral.discoverAllServicesAndCharacteristics(
505505
(err, services) => {
@@ -570,7 +570,7 @@ function peripheralTask(uuid, task, done, RED, forceConnect=false) {
570570

571571
function tearDown(err) {
572572
if (TRACE) {
573-
RED.log.info(`<peripheralTask> <${uuid}> Trying to disconnect,${err}`);
573+
RED.log.info(`<peripheralTask> <${uuid}> Trying to disconnect,(err:${err})`);
574574
}
575575
disconnectPeripheral(peripheral, () => {
576576
if (TRACE) {
@@ -611,7 +611,7 @@ function addErrorListenerToQueue(RED) {
611611
q.removeAllListeners('error');
612612
q.on('error', (err) => {
613613
if (TRACE) {
614-
RED.log.error(`[GenericBLE] ${err} :: ${err.stack || 'N/A'}`);
614+
RED.log.error(`[GenericBLE] error:${err} :: ${err.stack || 'N/A'}`);
615615
}
616616
});
617617
}
@@ -865,7 +865,7 @@ export default function(RED) {
865865
if (this.genericBleNode) {
866866
this.genericBleNode.on('ble-read', (uuid, readObj, err) => {
867867
if (err) {
868-
this.error(`<${uuid}> read: ${err}`);
868+
this.error(`<${uuid}> read: (err:${err})`);
869869
return;
870870
}
871871
let payload = {
@@ -876,7 +876,7 @@ export default function(RED) {
876876
try {
877877
payload = JSON.stringify(payload);
878878
} catch(err) {
879-
this.warn(`<${uuid}> read: ${err}`);
879+
this.warn(`<${uuid}> read: (err:${err})`);
880880
return;
881881
}
882882
}
@@ -887,7 +887,7 @@ export default function(RED) {
887887
if (this.notification) {
888888
this.genericBleNode.on('ble-notify', (uuid, readObj, err) => {
889889
if (err) {
890-
this.error(`<${uuid}> notify: ${err}`);
890+
this.error(`<${uuid}> notify: (err:${err})`);
891891
return;
892892
}
893893
let payload = {
@@ -898,7 +898,7 @@ export default function(RED) {
898898
try {
899899
payload = JSON.stringify(payload);
900900
} catch(err) {
901-
this.warn(`<${uuid}> read: ${err}`);
901+
this.warn(`<${uuid}> notify: (err:${err})`);
902902
return;
903903
}
904904
}
@@ -959,7 +959,7 @@ export default function(RED) {
959959
if (this.genericBleNode) {
960960
this.genericBleNode.on('ble-write', (uuid, err) => {
961961
if (err) {
962-
this.error(`<${uuid}> write: ${err}`);
962+
this.error(`<${uuid}> write: (err:${err})`);
963963
return;
964964
}
965965
if (TRACE) {
@@ -1063,10 +1063,10 @@ export default function(RED) {
10631063
};
10641064
schedulePeripheralTask(peripheral.uuid, task, (err) => {
10651065
if (TRACE) {
1066-
RED.log.info(`/__bledev/${address} END err:${err}`);
1066+
RED.log.info(`/__bledev/${address} END (err:${err})`);
10671067
}
10681068
if (err) {
1069-
RED.log.error(`/__bledev/${address} ${err}\n=>${err.stack || err.message}`);
1069+
RED.log.error(`/__bledev/${address} err:${err}\n=>${err.stack || err.message}`);
10701070
if (!res._headerSent) {
10711071
return res.status(500).send({ status: 500, message: (err.message || err) }).end();
10721072
}

0 commit comments

Comments
 (0)