Do thrown errors from Method server-side not work?


#1

I’ve got a server-only method that I’m throwing an error from:

export const addCard = new ValidatedMethod({
  name: 'addCard',

  validate(args) {
    check(args, {
      artistId: String,
      nickname: String,
      token: String,
    });
  },

  run({ artistId, nickname, token }) {
    if (Meteor.isServer) {
      const stripeAddCard = syncStripeFunc('customers', 'createSource');
      const customerId = getCustomerId(artistId || this.userId);

      try {
        return stripeAddCard(customerId, {
          metadata: { nickname },
          source: token,
        });
      } catch (e) {
        console.log('I caught something!', e);
        throw new Meteor.Error('card-auth-failed', e.raw);
      }
    }
  },
});

And when the user submits an invalid card, on the server I can see an error is dumped to the console, but on the client side, both error and result in the callback are undefined. Is this normal behavior?


#2

If server only, try throwing a regular Error