Skip to content

Commit

Permalink
command observers log commands which fail to execute correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewk committed Feb 17, 2015
1 parent 479a210 commit 7fc5ca5
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions lib/endpoint.js
Expand Up @@ -58,7 +58,7 @@ Endpoint.prototype.write = function(value) {
catch(e => {
log.error({
'source': this.toString(),
'message': 'Write command failed',
'message': 'Write failed',
'data': value
});
reject(new Error('Hardware failure'));
Expand All @@ -76,7 +76,7 @@ Endpoint.prototype.read = function() {
catch(e => {
log.error({
'source': this.toString(),
'message': 'Read command failed',
'message': 'Read failed',
'data': null
});
reject(new Error('Hardware failure'));
Expand All @@ -92,9 +92,23 @@ Endpoint.prototype.createCommandObserver = function() {
}

if (command.instruction.type === 'write') {
this.write(command.instruction.value);
this.write(command.instruction.value).
catch(e => {
log.error({
'source': 'command:' + this,
'message': 'Command failed',
'data': command
});
});
} else if (command.instruction.type === 'read') {
this.read();
this.read().
catch(e => {
log.error({
'source': 'command:' + this,
'message': 'Command failed',
'data': command
});
});
}
}
);
Expand Down

0 comments on commit 7fc5ca5

Please sign in to comment.