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.

EasyTechnical
0 practiced
Write a robust Bash script skeleton for a deployment step that must stop and cleanup on any failure. The script should demonstrate using set -euo pipefail, validating required environment variables, trapping EXIT to run cleanup, capturing the failing command's exit code, and printing a clear error message including the step name and exit code. Show the structure and explain why each pattern prevents silent failures.
MediumTechnical
0 practiced
Implement a Python decorator retry_on_exception that retries a synchronous function up to N times with exponential backoff and optional full jitter. Signature: retry_on_exception(retries=3, base_delay=0.5, max_delay=10, exceptions=(Exception,), jitter=True). Requirements: sleep between retries, re-raise the last exception if all retries fail, and preserve the wrapped function's metadata. Discuss limitations in multi-threaded environments.
MediumSystem Design
0 practiced
Design an automated rollback strategy for a microservice deployment when its error rate breaches the SLO. Include detection windows, metric thresholds, integration with CI/CD, safe rollback steps, canary considerations, and how to avoid rollback flapping. Describe which components own the rollback decision and how human override is handled.
HardTechnical
0 practiced
Design a metric and tracing strategy that quantifies the customer impact of error handling improvements. Define a set of metrics to track (for example user-facing error rate, mean time to recovery, retries per request), how to correlate these metrics with traces, and how to run an experiment or A/B test to validate that a new error handling change actually improves customer experience.
HardTechnical
0 practiced
Given a long-running Java service that has intermittent memory growth, propose code-level and JVM-level strategies to detect and prevent memory leaks. Discuss try-with-resources, reference types, leak detection libraries, how to capture and analyze heap dumps with jmap and jvisualvm, and a code example showing correct resource management in Java.

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.