My error message said the run was aborted only in its last four words
Bottom line: I wrote an error that aborts an entire run, and the message put that fact in its last four words. It should have come first. One person had to stop and correct it, and this happens often enough that it’s worth writing up.
What I wrote
Our tool runs a set of checks over a repository. We recently added a time limit on queries: if a query runs past it (30 seconds by default), the tool stops the whole run and returns an error. Nothing else gets checked.
This is the message I wrote:
`<query>` (<kind>) reached the query limit of 30 s, which ends the run
It reads in this order: a query name, its kind, a limit, a number, and only then “which ends the run.” When the query name is long, the part that tells you your run failed can start more than 85 characters in.
A reviewer read it in a status update and asked for the order to be reversed, along the lines of “Error: Run aborted (query exceeded runtime limit),” with details after that. They were right.
Why the order matters
- You don’t know what the sentence is about until you finish it. The first thing you see is an identifier. “Your run was aborted” comes last.
- Anything that shows only the start of a line drops the effect. CI summaries, alert titles, table cells and cut-off terminal lines all show “
<query>() reached the query…” and lose the only words that say the run failed. - You can’t tell how serious it is. “X reached the limit of 30 s” begins the same way a warning about slow work would. A failed run and a note about one slow item start with the same words.
What I should have written
Error: Run aborted (query exceeded runtime limit)
query: `<query>` (<kind>)
limit: 30 s
The order is:
- What happened to the thing you asked for
- Why it happened
- The names and numbers
- What to do next, if there’s anything to do
Why it happened
I wrote the sentence in the order the code finds things out: here’s the query, it ran, it hit the limit, so the run ends. That’s the natural order for the person writing it. The reader needs it the other way around. Three things pushed me further toward the wrong order:
- The requirement was written in cause-first order (“a query that reaches the limit must end the run”), and it listed the fields the error had to name without saying the error should state the abort. A list of fields led to a message made of fields.
- The messages around it had the same shape. Most of the roughly sixty error strings next to mine put the effect last, or left it out. I matched them. A few did lead with the effect (
`<path>` could not be read: <detail>), so the better pattern was already there and I didn’t use it. - Review checks completeness, not order. My message named the query, its kind and the limit, so it passed. Nobody, me included, asked what its first words were. The string was then quoted unchanged in a progress report marked “Done.” The report’s own sentence led with the effect, but the string it quoted didn’t.
What I’m changing
A test anyone can apply: cut the text after its first clause or first line. Does the reader still know what happened? For my message, the cut leaves “<query> (
Fix the pattern, not only the one message. Fixing a single message’s order means the shape itself was wrong. I’m going through the sibling messages and changing the ones with the same problem. Two examples:
| Before | After |
|---|---|
`--statement X` names a statement no entry of the package enforces, so the run would check nothing |
Nothing to check: no entry of the package enforces `X` |
`<file>` names the package set A, and the checker builds packages with the package set B |
Package set mismatch: `<file>` names A, the checker builds with B |
The second one is worse than my original. It states two facts joined by “and” and never says they conflict or that nothing ran.
Write the order into requirements. When a requirement lists what an error must name, it should first say what the error must state. For example: “states that the run was aborted and why, then names the query, its kind and the limit.”
Read the string as its user before passing it on. If I quote a user-facing message in a report, I read it as the person at the terminal would before I mark it done. Accuracy is one check and order is another.
This isn’t only about error messages
This is the same idea as designing a screen people can skim, applied to sentences. Anything written for a reader should lead with the bottom line, and the details should be safe to skip:
| Text | Lead with | Not with |
|---|---|---|
| Error message | What failed or was stopped | The object, the parameter, the history |
| Log line, alert title | What changed | The component’s narration |
| Status report | Done, not done, or blocked | The steps taken |
| Issue title or outcome | The result | The investigation |
| Commit subject | What changed | Why someone looked |
| Answer to a question | The answer | The reasoning |
| Review finding | The defect | How it was found |
I also checked whether we already had a lesson about this. We have related ones: give a stop a specific reason, size text for the space where it’s shown, read a worker’s claim before relaying it. None of them covers the order of information within a sentence. My message met all of them and still made the reader wait until the end to learn what happened. This post is the first record, so the next time this shows up in an error, a log line or a status update, it should be counted against this one.