0

I have a simple function in Parse Cloud Code (with express.js), but I'm having trouble understanding the propagation of Parse.Promise.error() in this context. When I hit the function, it returns nothing and the console says "success/error was not called." Shouldn't the error be caught?

app.post('/test', function(req, res) {
  var TestObject = Parse.Object.extend('TestObject');
  query = new Parse.Query(TestObject);
  query.first().then(function(rr) {
    return Parse.Promise.error();
    res.send('should not reach this');
  }, function(error) {
    res.send('error');
  });
});
rink.attendant.6
  • 44,500
  • 61
  • 101
  • 156
user5304181
  • 135
  • 3
  • The error handler that goes into `then` does only handle errors in the promise (`query.first()`), not errors in the success handler. Chain an extra `.catch()` (or `then()`) on the returned promise. – Bergi Sep 05 '15 at 19:33
  • This did it. Thanks, @Bergi. Sorry for the duplicate question. – user5304181 Sep 05 '15 at 19:37
  • No need to be sorry, it's not an obvious issue :-) Just wanted to avoid repeating the whole explanation. – Bergi Sep 05 '15 at 19:39

0 Answers0