It’s because the Meteor.Error constructor is meant to accept a “code” as its first argument, with the human-readable message being the second argument. So, the intended usage is something like:
throw new Meteor.Error('my-code', 'This is my error message');
That will give you an error message like this:
This is my error message [my-code]
And if you use the error’s reason field instead, it doesn’t include the code in brackets:
Thanks for your help! I took another look at the meteor docs and source code too. Sounds like I should change how I’m handling errors on the client side.
If anyone has any best practices to share on that, would be interested to learn.
On that note, while the second parameter of Meteor.Error, the reason, is documented as being of type string, you can actually pass an object too, and, even if thrown on the server, the client will receive it.
This comes quite handy if you intend to display a more elaborate message with various context information about the error occurred, and especially if you need to do it in various languages.