Skip to content
This repository was archived by the owner on Aug 17, 2019. It is now read-only.
This repository was archived by the owner on Aug 17, 2019. It is now read-only.

Pass on the error code from Flickr to the callback function. #106

@ajainarayanan

Description

@ajainarayanan

TL;DR

  • Is it possible to pass on the error object returned by flickr api instead of just the error message

Longer version

This is the scenario I am seeing,

  1. Node server exposes some API for accessing photos
  2. Internally uses flickr.photos.* function get a particular photo
  3. Gets a query for a photo that doesn't exists.
  4. flickrapi throws an error which is then passed on to the client
  5. Node has to check with the message and figure out what the error is instead of the code.

The issue in Step 4 is a error object is thrown with just the message instead of the actual error from flickr server. The error code could be easier reference to find the type of error to be passed on to the client.

We have flickr/methods/flickr.photos.*.json files that properly document the arguments and error response codes however when the error finally reaches the callback it is just the message instead of the response from flickr which includes {code, stat, message}. Would be nice if those could be exposed as well in addition to the error object.

This is my setup,

Flickr.authenticate(flickrOptions, function(error, flickr) {
  if (error) {
    console.log("Error instiating flickr API object: ", error);
  }

  ...
  flickr.photos.getSize(flickrOptions, (err, result) => {
    // send response.
  });
});

If authors agrees for an additional config that will return error from flickr server in addition to the message, would gladly open a PR to add it :)

Note:

Sorry if this is already possible and I am just missing some config. Looked through the code and found flickrapi/src/utils.js:317. Noticed we get the error code, stat and message from flickr but in-turn create a error object with just the message and pass that from there on.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions