CS FundamentalsModerateTCS Digital · Infosys

A service catches every exception in a broad try/except, logs nothing and returns an empty list, so a database outage looks like 'no results'. Which statement best describes the problem?

  1. A. It is good defensive programming
  2. B. It is required by the Single Responsibility Principle
  3. C. It swallows errors, hiding the failure from callers and operators; it should catch only expected exceptions and let others propagate or fail fast with logging
  4. D. It improves performance by avoiding stack traces

Correct answer: C. It swallows errors, hiding the failure from callers and operators; it should catch only expected exceptions and let others propagate or fail fast with logging

Silent catch-alls turn outages into wrong answers that are hard to diagnose. Handle what you can recover from, and surface the rest with context.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic