Disable logging check(arg, String) error in Publish Function?


#1

I noticed that if I throw my own Meteor.Error in the publish function, Meteor does not pipe any text to standard out. This is good. If I use the check function in my publish function, it makes the code very clean. Unfortunately, any time check throws, it will spit out the error to the console … I would prefer if it did not.

Two Solutions - Are there better solutions?

//in the top of a publish function, ugly solution.
try {
 check(id, Id)
} catch (error) {
 throw new Meteor.Error('malformed')
}
//in the top of a publish function, better solution.
if (!Match.test(id,Id)){
 throw new Meteor.Error('malformed')
}

The latter solution is better, I think. I would rather there be a way to not have Meteor log the Match.Error thrown in a publish function. Is there something simple I’m missing?

Thanks!


#2

Likely this is just a minor inconsistency in how check() works? Submit an issue or even a PR since it’s such a small change and see what the core devs think about this?
But the thinking about check() may also be that it should indeed do more than just report to the client, but also boldly state in the server-side log that something is probably off, because a variable was expected to be formed a certain way (of certain type/value) but was not, so that would indicate a programming error and should be attended to by the developer, thus annoying same with a log message.