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?
- A. It is good defensive programming
- B. It is required by the Single Responsibility Principle
- 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
- 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.
Practise more Software Engineering, Git and Cloud Basics questionsSoftware Engineering, Git and Cloud Basics: notes and key points
More Software Engineering, Git and Cloud Basics questions
- How many of these defend against SQL injection in a login query: (1) parameterised queries / prepared statements, (2) escaping quotes by…
- A document-editor framework defines an abstract Application class with a method newDocument() that calls createDocument(); each concrete…
- An object adapter and a class adapter both make class Legacy fit interface Target. Which statement is correct?
- Both Facade and Mediator sit between groups of objects. What is the essential difference?
- A Customer may or may not have a discount policy. Instead of writing if policy is not None: total = policy.apply(total) everywhere, the…
- Which form of dependency injection makes required dependencies explicit and allows the object to be immutable and fully initialised as…