Skip to content
Sharp

Exceptions · interview question

In an e-commerce checkout flow, why is catching only specific exceptions considered a best practice?

Multiple choiceHardchapter-6-curatedpremiumexceptionsexceptions-basics
Choose one answer
Answer and explanation

Correct answer

C. To ensure only known and handled exceptions affect the flow.

Why

Catching specific exceptions allows developers to handle only anticipated and relevant errors, maintaining control over the flow and avoiding unintended consequences from catching all exceptions indiscriminately.

Test yourself on Exceptions

A free test with instant, explained results. No account needed.

Start free test
All Exceptions questions →