bert icon indicating copy to clipboard operation
bert copied to clipboard

class is not applied when providing dynamic message

Open Muphet opened this issue 8 years ago • 1 comments

i am trying to show alert after method returns error. When i provide err message and apply it to bert.alert, class of that alert is not applied at all (switches to default fixed-top info whatever it is). When i change err to string, it suddenly works fine.

Meteor.call('invite', user, (err, res) => {
        if(err)
          Bert.alert(err, 'warning', 'fixed-top');
});

server:

invite: function(user){
 if(invited(user)){
  let err = "user already invited";
  throw new Meteor.Error(err);
 }
 return;
}

any idea why class is not displayed? or better way of triggering alerts on method error?

Muphet avatar Feb 06 '17 14:02 Muphet

In your error code, the first argument is just a generic identifier, while the second argument is the actual message sent down to the client. So...

throw new Meteor.Error('500', 'user already invited');

Then in your Bert code do Bert.alert(error.reason, 'warning', 'fixed-top');

themeteorchef avatar Feb 07 '17 19:02 themeteorchef