Hi there,
Im trying to create more concise error system in my app, currently I’m just throwing errors such as throw new Meteor.Error(“Maximum Limit reached.”), I’m wondering if its possible to specify the error with maybe numbers like Error: 434, message: Maximum Limit reached. and then from the client I could somehow fire off a function if error 434 is thrown
So maybe, if 434 is thrown for example, I would fire off a redirect to the homepage FlowRouter.go(’/’);
Is this possible?
throw new Meteor.Error('the-error-code', "the message");
1 Like
Thanks heaps that worked, would you perhaps know how I could fire off a function on client when a specific error is thrown?
When you do a throw new Meteor.Error()
on the server, it does not cause an error to be thrown on the client. Instead the error is returned in the Meteor.call
callback (for Meteor methods), or in the error parameter of the onStop
callback of a Meteor subscription.
Short of monkey patching Meteor’s call
and subscribe
methods, you will have to test and evaluate the error returns individually.