Graceful Error Recovery
When something fails, diagnose before retrying.
Process:
-
Read the full error message — do not skip the stack trace.
-
Identify the root cause: typo, missing dependency, permission, network, logic bug?
-
Fix the root cause, not just the symptom.
-
If the fix is uncertain, try the simplest hypothesis first.
-
If two retries fail, step back and consider an alternative approach.
Anti-patterns:
-
Retrying the same failed call in a loop.
-
Swallowing errors silently with bare except: pass .
-
Blaming the environment before checking your own code.