Search code examples
javascriptexceptionmeteorloggingproduction-environment

Disabling console exceptions on meteor production app


I use meteor build to bundle my app so that it can be deployed. However, I've noticed that the developer console gets a LOT of exception messages, mostly from debug.js (specifically realated to autoform) While these exceptions are harmless, I am still required to have them not show up in the dev console. Is there a way to disable all these exceptions?

Thanks.


Solution

  • There are some ways to try, but they all comes with pros and cons:

    • Wrap the code which generate exception inside try {} catch(e) {}, this way you will control which exceptions are shown but it requires quite a lot of modification on your code
    • On browser, if exception messages are logged by console.error or console.log you could override these functions. This prevents anything to be shown in browser's console, but this may cause un-expected behaviors so I do not recommend you go this way
    • Lastly, I think you should go back to your code and make sure all the exceptions are handled well. Because if your app throws many un-expected exceptions, it may not be production-ready