Skip to content

Commit

Permalink
fix: fixed error reporting so catch node could be used
Browse files Browse the repository at this point in the history
Closes #119
  • Loading branch information
zachowj committed May 22, 2019
1 parent 6a3376b commit 861c8e8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 18 deletions.
6 changes: 4 additions & 2 deletions nodes/call-service/call-service.js
Expand Up @@ -84,7 +84,8 @@ module.exports = function(RED) {
this.error(
`call service node is missing api "${
!apiDomain ? 'domain' : 'service'
}" property, not found in config or payload`
}" property, not found in config or payload`,
message
);
this.setStatusFailed('Error');
return;
Expand Down Expand Up @@ -121,7 +122,8 @@ module.exports = function(RED) {
this.error(
`Call-service API error.${
err.message ? ` Error Message: ${err.message}` : ''
}`
}`,
message
);

this.setStatusFailed('API Error');
Expand Down
11 changes: 3 additions & 8 deletions nodes/get-history/get-history.js
Expand Up @@ -127,16 +127,11 @@ module.exports = function(RED) {
message.enddate = enddate || null;
message.entityid = entityid || null;
} catch (err) {
let errorMessage =
'Error get-history, home assistant api error.';
if (this.utils.selectn('response.data.message', err))
errorMessage = `${errorMessage} Error Message: ${
err.response.data.message
}`;
this.error(errorMessage);
let errorMessage = `Error get-history: ${err.message}`;
this.error(errorMessage, message);
this.setStatusFailed('Error');

return null;
return;
}

if (this.nodeConfig.output_location === undefined) {
Expand Down
8 changes: 1 addition & 7 deletions nodes/render-template/render-template.js
Expand Up @@ -100,13 +100,7 @@ module.exports = function(RED) {
this.setStatusSuccess();
})
.catch(err => {
this.error(
`Error get-template, home assistant api error. ${
this.utils.selectn('response.data.message', err)
? `Error Message: ${err.response.data.message}`
: ''
}`
);
this.error(`Error get-template: ${err.message}`, message);
this.setStatusFailed('Error');
});
}
Expand Down
2 changes: 1 addition & 1 deletion nodes/wait-until/wait-until.js
Expand Up @@ -78,7 +78,7 @@ module.exports = function(RED) {

this.send([this.savedMessage, null]);
} catch (e) {
this.error(e);
this.error(e, this.savedMessage);
}
}

Expand Down

0 comments on commit 861c8e8

Please sign in to comment.