Interview Prep/Python for DevOps/Testing, CI/CD, packaging & services

Code review shows `except Exception as e: logger.error(e)` everywhere in a new tool. What feedback do you give?

BeginnerScenarioTesting, CI/CD, packaging & services
Answer

Situation read → Errors are swallowed and tracebacks lost.

What I'd do →

  1. Catch specific exceptions where you can handle them (ClientError with a specific code, FileNotFoundError).
  2. Use log.exception(...) to keep the traceback, and add context (which resource, which region).
  3. Re-raise or exit non-zero when you cannot recover.
  4. Keep one broad catch at the CLI entry point that logs and exits 1.

Why → Swallowed exceptions make tools report success while failing.

Interview tip → "Catch narrow, log with context, fail loudly."

All Python for DevOps questions Roadmap: Python for automation

More on Testing, CI/CD, packaging & services