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
85 practiced
Write an Express.js error-handling middleware that:
- Captures exceptions from routes and controllers- Logs structured errors with correlation id and stack trace (development only)- Returns sanitized JSON responses to clients (no stack traces in production)
Show example middleware code and explain how to integrate it into an Express app.
MediumTechnical
85 practiced
Implement a small Node.js logger wrapper that accepts a request-scoped correlationId and ensures every log line includes it. Requirements:
- The logger should gracefully handle objects that cannot be serialized (circular refs) without throwing.- Provide methods info, warn, error that accept message and metadata.- Show how the logger would be injected into an Express request lifecycle.
Provide sample code (ES2019+).
HardTechnical
72 practiced
Design a CI/CD strategy to catch regressions in error handling and observability before they reach production. Include unit tests, integration tests, contract tests, and failure-injection (chaos) tests. Explain how to gate deploys based on test results and post-deploy observability checks that can auto-roll back faulty releases.
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.
MediumTechnical
105 practiced
Design a retry strategy for client-side requests that includes exponential backoff, jitter, maximum attempts, and integration with a circuit breaker. Provide pseudocode or a function signature and explain how you would avoid the thundering herd problem and protect downstream services under load.

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.