DEV Community

Peter Gašparík
Peter Gašparík

Posted on

1

Don't ignore caught exceptions

I had a really bad day because of a function, that ignored all caught exceptions. Code looks something like this and it was part of a third party library, that I was using. I didn't know about implementation details at the time.

function doSomething() {
    try {
        // some code
    } catch (err) {}
}

Debugging function like this, that never crashes and never prints any error messages, is a nightmare. I usually trust third party libraries and at first assume that problem has to be with my code. That’s why I spent hours debugging this.

So, what to do with exceptions? I think it's valid to let other programmers (those that use this library) to handle the exception. Especially, if you have no idea what to do with it.

What do you think? Is there a situation where this is acceptable? Maybe production environment? I personally don't think so, because you want to know about errors in production and store them somewhere.

SurveyJS custom survey software

Simplify data collection in your JS app with a fully integrated form management platform. Includes support for custom question types, skip logic, integrated CCS editor, PDF export, real-time analytics & more. Integrates with any backend system, giving you full control over your data and no user limits.

Learn more

Top comments (0)

SurveyJS custom survey software

Build Your Own Forms without Manual Coding

SurveyJS UI libraries let you build a JSON-based form management system that integrates with any backend, giving you full control over your data with no user limits. Includes support for custom question types, skip logic, an integrated CSS editor, PDF export, real-time analytics, and more.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay