mckelvey / instagram-node-lib

The Instagram Node Lib is a helper library for node that makes communicating with the Instagram API easy.
http://david.mckelveycreative.com/
Other
303 stars 49 forks source link

Issues with error function being called from other points in code #19

Open rickwaugh1 opened 10 years ago

rickwaugh1 commented 10 years ago

Hi, not sure if this is an issue with the library or not, but we are having a problem, where after the instagram module is called, another piece of code throws an error,(example was a syntax error in an array union, we ended up trying to call the array as function because of missing period,) and then the error function we had created in the object passed into the instagram library ended up being called with the syntax error.

So sequence: We call the instagram library with the following object. We exit successfully, and move on in the code. A totally unrelated syntax error is thrown. The error function in this object is called with that error, essentially eating the error and hiding it.

The obj looks like this:

Instagram.users.info(
{
    user_id: 'self',
    complete: function(res)
    {
        if(!res || !res.id)
        {
            error_found = true;
            service_result = {"service":service.source_service,"source_service_id":service.source_service_id,"token":service.token,"message":"Unspecified Problem - no data returned","error":true};
        }
        else if (res.id != service.source_service_id)
        {
            error_found = true;
            service_result = {"service":service.source_service,"source_service_id":service.source_service_id,"token":service.token,"message":"Instagram User Id Not Authorized for This Token","error":true};
        }
        else
        {
            var parsed_result = parse_users_array([res]);
            service_result = {"service":service.source_service,"source_service_id":service.source_service_id,"token":service.token,"token_secret":service.token_secret,"error":false,"display_name":parsed_result[0].display_name,"account_name":parsed_result[0].account_name,"profile_image_url":parsed_result[0].profile_image_url};
        }

        next(null,service_result,error_found);
    },

    error: function(error_message,error_object)
    {
        error_found = true;
        service_results = {"service":service.source_service,"source_service_id":service.source_service_id,"token":service.token,"message":error_message,"error":true};
        next(error_object,service_results,error_found);
    }

});