cloudinary_npm icon indicating copy to clipboard operation
cloudinary_npm copied to clipboard

Reject promise for error codes 400, 401, 404, 420 and 500 during file upload

Open gauravhub opened this issue 12 years ago • 1 comments

Inside handle_repsone method (file: lib/uploader.coffee), for HTTP error codes 400,401,404,420 and 500, promise is being resolved deferred.resolve(result) (line number: 178) with result object holding the error object. Instead, shouldn't the promise be rejected with preferably error object deferred.reject(result["error"]) or result object deferred.reject(result)?

gauravhub avatar Oct 15 '14 15:10 gauravhub

Its to be expected but just want to highlight that anyone else who was used to handling errors like:

cloudinary.uploader.upload(
  ...,
  function (result) {
    if (result.error) { // TODO: source code needs to change from the old-style of handling the resolved error
      promise.reject(result);
    } else {
      console.log('uploadProductImage() - resolved cloudinary.uploader.upload()');
      promise.resolve(result);
    }
  },
  ...

should update their own source code, when upgrading to v1.0.13

pulkitsinghal avatar Jan 30 '15 21:01 pulkitsinghal