DEV Community

loading...

Discussion on: Exceptions are meant to be exceptional

Collapse
wkrueger profile image
Willian Krueger • Edited

IMHO, in the huge moajority of cases, try-catches fall into one of the following uses:

  1. "Inner" try-catches may translate or augment the error messages and throw them again. Literally, error middlewares.
  2. Top-level try-catches will usually display the error to user and/or send to logger and may not rethrow the error.

Not rethrowing an error in an inner try-catch is very rare, and 99% of the times, is wrong.

We still need to use exceptions. Dont misinterpret the article. Exceptions have an unique property: bubbling, and thats why they are necessary. Just dont use them where they are not meant to be used.