Question
When should a Python developer choose Exceptions and Custom Errors deliberately?
- Choose Exceptions and Custom Errors mainly when you want to postpone validation and fix issues manually later.
- Choose Exceptions and Custom Errors whenever you want the code to look more advanced, even if the design gets less clear.
- Raise and translate exceptions deliberately when callers need a clearer contract or recovery decision than a raw low-level failure provides.
- Choose Exceptions and Custom Errors only to avoid modeling the real data shape or domain contract explicitly.
Hint
Think about the production scenario where the choice genuinely improves the code.
Answer and rationale
Correct answer: C. Raise and translate exceptions deliberately when callers need a clearer contract or recovery decision than a raw low-level failure provides.
Raise and translate exceptions deliberately when callers need a clearer contract or recovery decision than a raw low-level failure provides. Interviewers often ask this to see whether you can connect the concept to real design decisions.
Track: Python