How to Read an Error Message Before You Change Any Code
Read an error message before changing code: copy the exact text, find your own line, separate fact from assumption, and then change only one thing at a time.
When a program fails, the first edit is usually the one I regret. I read an error message in four passes before I touch the code. The same reading order works in more than one language. Python's tutorial shows the pattern: the last line says what happened, and the stack trace above it shows where the failure was detected. https://docs.python.org/3/tutorial/errors.html
Copy the error text first
Copy the exact text. A paraphrase drops the line number, the error code, and the file name. Those details are the part you will need when you search or when you come back an hour later.
Find the first frame in your code
Library frames matter, but the earliest line in your own files is usually where you can act. Start there instead of editing a dependency you did not write.
Separate the failure from the assumption
"Cannot read property of undefined" tells you a value was missing. It does not tell you which earlier function was supposed to set it. Write down the failure in one sentence, then write down what you had assumed. The gap between those two sentences is the lead.
Change one thing, then rerun the same case
If you change three things, you no longer know which change mattered. Most bugs I fix this way are a wrong path, a missing check, or a value that arrived later than I thought. Reading the message carefully is faster than guessing.
Disclosure: I used an AI assistant to draft this and then checked the explanation against the Python documentation.
原文:https://www.a8q9.cn/en/article/how-to-read-an-error-message-before-you-change-any-code-32dd07.html