Skip to content

Improvements on error handling in forecastio and instagram nodes #140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
4 changes: 2 additions & 2 deletions forecast/forecastio.js
Original file line number Diff line number Diff line change
@@ -26,8 +26,8 @@ module.exports = function(RED) {
}

if (90 >= lat && 180 >= lon && lat >= -90 && lon >= -180) {
node.lat = lat;
node.lon = lon;
node.lat = lat.trim();
node.lon = lon.trim();
} else {
return callback(RED._("forecastio.error.invalid-lat_lon"));
}
14 changes: 10 additions & 4 deletions instagram/instagram.js
Original file line number Diff line number Diff line change
@@ -79,9 +79,10 @@ module.exports = function(RED) {
node.ig.user_media_recent('self', { count : 1, min_id : null, max_id : null}, function(err, medias, pagination, remaining, limit) {
if (err) {
node.warn(RED._("instagram.warn.userphoto-fetch-fail", {err: err}));
return;
}

if(medias.length > 0) { // if the user has uploaded something to Instagram already
if(typeof medias !== 'undefined' && medias.length > 0) { // if the user has uploaded something to Instagram already
node.latestSelfContentID = medias[0].id;
}

@@ -97,9 +98,10 @@ module.exports = function(RED) {
node.ig.user_self_liked({ count : 1, max_like_id : null}, function(err, medias, pagination, remaining, limit) {
if (err) {
node.warn(RED._("instagram.warn.likedphoto-fetch-fail", {err: err}));
return;
}

if(medias.length > 0) { // if the user has liked something to Instagram already
if(typeof medias !== 'undefined' && medias.length > 0) { // if the user has liked something to Instagram already
node.latestLikedID = medias[0].id;
}

@@ -120,8 +122,9 @@ module.exports = function(RED) {
node.ig.user_media_recent('self', { count : 1, min_id : null, max_id : null}, function(err, medias, pagination, remaining, limit) {
if (err) {
node.warn(RED._("instagram.warn.userphoto-fetch-fail", {err: err}));
return;
}
if(medias.length > 0) { // if the user has uploaded something to Instagram already
if(typeof medias !== 'undefined' && medias.length > 0) { // if the user has uploaded something to Instagram already
if(medias[0].type === IMAGE) {
if(medias[0].location) {
if(medias[0].location.latitude) {
@@ -172,8 +175,9 @@ module.exports = function(RED) {
node.ig.user_self_liked({ count : 1, max_like_id : null}, function(err, medias, pagination, remaining, limit) {
if (err) {
node.warn(RED._("instagram.warn.likedphoto-fetch-fail", {err: err}));
return;
}
if(medias.length > 0) { // if the user has liked something to Instagram already
if(typeof medias !== 'undefined' && medias.length > 0) { // if the user has liked something to Instagram already
if(medias[0].type === IMAGE) {
if(medias[0].location) {
if(medias[0].location.latitude) {
@@ -235,6 +239,7 @@ module.exports = function(RED) {

if (err) {
node.warn(RED._("instagram.warn.latest-media-fetch-failed", {err: err}));
return;
}

if(medias) {
@@ -401,6 +406,7 @@ module.exports = function(RED) {
client_id: credentials.client_id,
redirect_uri: credentials.redirect_uri,
response_type: "code",
scope: "public_content",
state: node_id + ":" + credentials.csrfToken
}
}));
6 changes: 3 additions & 3 deletions instagram/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name" : "node-red-node-instagram",
"version" : "0.1.0",
"version" : "0.1.1",
"description" : "Node-RED nodes that get photos from Instagram",
"dependencies" : {
"request":"~2.40.0",
"instagram-node":"0.5.1"
"instagram-node":"0.5.8"
},
"repository" : {
"type":"git",
@@ -22,4 +22,4 @@
"email": "[email protected]",
"url": "http://nodered.org"
}
}
}