← Table of Contents · Page 131 of 868
RUNTIME EXECUTION ENVIRONMENTS
Part 6 of 10
GRACEFUL FAILURE
Things will go wrong.
A program will crash, a request will time out, a file will be missing, a permission will be denied.
Graceful failure means ending cleanly, with a clear report, when something goes wrong.
The opposite is a silent crash, an endless loop, or a mysterious message that says only "error."
Graceful failure has several parts.
First, catch the error instead of letting it explode.
Second, classify it: is it temporary (a timeout), permanent (a missing file), or a policy block (permission denied)?
Third, decide the response for that class: retry temporary errors with limits, stop and explain for permanent ones, and escalate to a person for policy blocks.
Fourth, tell the user in plain words what happened, what was done, and what to do next.
Fifth, log the details for engineers, including the time, the tool, the inputs, and the error text, being careful not to log secrets.
Sixth, clean up: close files, stop stray processes, and release locks, so the failed run does not leave a mess behind.
Seventh, preserve partial results when they are useful, as the step-limit example in Chapter 9 showed.
A graceful message is honest, specific, and actionable.
It says what was attempted, what went wrong, what partial output exists, and what the recommended next step is.
Advertisement
Read Aloud:
0:00 / 0:00