7

I usually just block every possible entry point of errors instead of handling them directly with try-catch or on-error callbacks. Is that a good practice?

In case you ask, yes, i am that lazy.

Comments
  • 4
    I'd say yes. It's always better to prevent exceptions if you can. Try catch should be for things you can't predict, like io/network errors.
  • 1
    @spongessuck has the right idea. Anticipate and avoid as many modes of failure as is reasonable. For everything else, there's catch.
  • 1
    Yeah I'd say it's lazier to wrap things in a try block than handle the possible error paths in your regular logic.

    Depending on their implementation, exceptions can actually be quite expensive, so it's generally better to avoid them than to just blanket catch everything.
Add Comment