Skip to content

Commit

Permalink
Fix error messages on invalid directions API requests and add a "succ…
Browse files Browse the repository at this point in the history
…ess" node status (#319)

* Google Directions: Add success status and correct error message on failure

* Update translation en-US

* Update german translations
  • Loading branch information
AndLindemann committed Jun 14, 2024
1 parent d025f03 commit faae0fe
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
13 changes: 5 additions & 8 deletions google/directions.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ module.exports = function(RED) {
lon: newMsg.payload.routes[0].legs[0].end_location.lon
}
};
node.status({fill:"green",shape:"ring",text:"directions.status.success"});
cb(newMsg);
} else if (data.status == 'ZERO_RESULTS') {
newMsg = cloneMsg(msg); //quick clone msg
Expand Down Expand Up @@ -187,21 +188,17 @@ module.exports = function(RED) {
break;
case 'REQUEST_DENIED':
error.code = 400;
error.message = RED._("directions.error.request-denied");
error.message = RED._("directions.error.request-denied");
break;
case 'UNKNOWN_ERROR':
error.code = 500;
error.code = 500;
error.message = RED._("directions.error.unknown-error");
break;
break;
default:
error.code = 500;
error.message = RED._("directions.error.unknown-error");
}
throwNodeError({
code: 400,
message: RED._("directions.error.no-destination"),
status: 'MISSING_VALUES'
}, msg);
throwNodeError(error, msg);
return;
}
}
Expand Down
3 changes: 2 additions & 1 deletion google/locales/de/directions.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"name": "Name"
},
"status": {
"failed": "Fehlgeschlagen"
"failed": "Fehlgeschlagen",
"success": "Erfolgreich"
},
"error": {
"no-origin": "Bitte Startpunkt angeben",
Expand Down
3 changes: 2 additions & 1 deletion google/locales/en-US/directions.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"name": "Name"
},
"status": {
"failed": "failed"
"failed": "failed",
"success": "success"
},
"error": {
"no-origin": "Please supply an origin value",
Expand Down

0 comments on commit faae0fe

Please sign in to comment.