throwStubExceptions produce uncaught errors

How is throwStubExceptions used? When throwStubExceptions is false the error is logged to console.

Meteor.apply('myMethod', [], {throwStubExceptions:false}, function(error, result) {
  if (error) {
    console.log(error);
  }
})

Meteor.methods({
  myMethod: function() {
    throw new Meteor.Error('bad stuff happened');
  }
})

If throwStubExceptions is changed to true then it makes an uncaught error and error in the callback is undefined. Is this a bug?

1 Like

We are also seeing this, I’m not sure if this forum is the right place to track it… ?

I’m pretty sure the behaviour in the OP is as documented, especially given the method code used.

Ok, but how can I catch the errors on the client?

I just use try/catch:

try {
  Meteor.apply('abc', parameters, { throwStubExceptions: true }, (err, res) => {
    console.log('method returned', err, res);
  });
} catch (error) {
  console.log('caught error', error);
}
1 Like

That seems to work, thanks!

1 Like