InterviewStack.io LogoInterviewStack.io

Error Handling and Code Quality Questions

Focuses on writing production quality code and scripts that are defensive, maintainable, and fail gracefully. Covers anticipating and handling failures such as exceptions, missing files, network errors, and process exit codes; using language specific constructs for error control for example try except blocks in Python or set minus e patterns in shell scripts; validating inputs; producing clear error messages and logs; and avoiding common pitfalls that lead to silent failures. Also includes code quality best practices such as readable naming and code structure, using standard libraries instead of reinventing functionality, writing testable code and unit tests, and designing for maintainability and observability.

MediumTechnical
75 practiced
Instrument a function to log structured context (user_id, request_id, latency_ms, status) before and after calling an external service in Python. Provide example code using a logger that emits JSON-compatible dictionaries and explain how these logs enable troubleshooting without leaking PII.
EasyBehavioral
99 practiced
Tell me about a time you refactored or fixed code that was failing silently (e.g., swallowed exceptions, empty catch blocks). Use the STAR structure (Situation, Task, Action, Result). Include how you detected the issue, the change you made to prevent recurrence, and what you learned.
HardTechnical
94 practiced
You run a nightly batch job that processes millions of records and occasionally crashes mid-run. Design a resume/restart mechanism so that on restart the job continues from the last consistent checkpoint without duplicating side effects. Discuss checkpoint granularity, idempotency, transactional updates, and trade-offs between throughput and checkpoint frequency.
EasyTechnical
81 practiced
Create a Python CLI using argparse that accepts --input <path> and --mode <fast|safe>. Validate that the input file exists, the mode is one of the allowed values, and produce clear, non-cryptic error messages with non-zero exit codes for failures. Provide sample code and at least two example error messages the CLI should print.
HardTechnical
93 practiced
Discuss the trade-offs between failing-fast (abort on first serious error) and attempting to continue processing in a high-throughput data pipeline. What metrics would you track to make operational decisions (error rate, error cost, customer impact), and how would you design safeguards to choose between both behaviors dynamically?

Unlock Full Question Bank

Get access to hundreds of Error Handling and Code Quality interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.