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.

HardTechnical
0 practiced
How do you ensure that error messages and logs never leak sensitive information (PII, secrets, tokens)? Propose a redaction strategy, runtime checks, and CI/test-time safeguards to catch accidental sensitive data in logs. Include examples of what to redact and how to verify the approach.
MediumTechnical
0 practiced
Compare and contrast catching and rethrowing exceptions vs wrapping exceptions with additional context (e.g., throw new DatabaseException("failed to load user", e)). When should you prefer wrapping, when should you rethrow the original, and what are the trade-offs for stack traces and observability?
EasyTechnical
0 practiced
You have a Bash script that sometimes exits with status 0 even though a command failed earlier because errors were swallowed. Explain what `set -e` does, why it does not always prevent silent failures, and demonstrate a small robust pattern (using `set -e`, `trap`, or explicit checks) to fail fast and clean up temporary files.
Provide a short example script that downloads a file, processes it, and always removes temp files even on errors.
HardSystem Design
0 practiced
Design an error classification and metric system for a web platform: define categories (validation, client-misuse, infrastructure, transient-network, bug), required fields in each error event, and how to map them to alert priorities and SLO impact. Provide examples for three error events and show how they would appear in dashboards.
HardTechnical
0 practiced
Design and implement (or provide pseudocode for) a thread-safe retry queue in Java that accepts Runnable tasks, retries failed tasks up to N times with backoff, and records failure metrics (attempts, last error). Requirements:
- Support configurable concurrency level.- Ensure that permanent failures (after max attempts) are logged and exposed via a metrics endpoint.- Avoid deadlocks and ensure graceful shutdown drains or persists the queue.
Explain choices for task persistence vs in-memory only and how to handle poison messages.

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.