[Solved] - Handling 'check' package server errors

Whenever I send incorrect argument type to server method I get a typical error - Exception while invoking method 'method name' Error: Match error: Expected number, got string.
Now, suppose a cool hacker abuses my server by constantly calling a method. I understand that I can rate limit this, but it still will throw many many errors in server console.
How can I keep it cleared?

bumb…anyone?

check just throws an exception when the check fails, so you can always just swallow the exception yourself to keep it out of the console/logs. Something like:

Meteor.methods({

  swallowCheckError: function (param1) {
    var checkPassed = false;
    try {
      check(param1, String);
      checkPassed = true;
    } catch (err) {
      // Gulp - delicious error swallowed
    }   
    if (checkPassed) {
      console.log('all good');
    } else {
      console.log('oh no!');
    }   
  }

});
2 Likes