bert
bert copied to clipboard
class is not applied when providing dynamic message
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?
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');