IntermediateLesson 3 of 59 min read
Reading an error and getting it fixed
A course from the Academy: Coding with AI, even if you're not a developer
Go to the quiz ↓An error isn't a failure: it's a message telling you what's wrong. Most of the time, passing it on properly to the AI is enough to get it fixed. You just need to know where to find it.
Where the message hides
- In a web page: the site looks wrong or a button does nothing? Open the browser's developer tools (F12 on a computer, or right-click then "Inspect"), "Console" tab. Errors show up in red.
- In a program run from a terminal: the message appears at the end, often over several lines. The last line usually gives the type of error; the lines above show where it happened.
- On a creation platform: there's often an errors or "logs" panel, the event journal.
Reading without panicking
Spot three things: the error type (for example "TypeError" or "FileNotFoundError"), the file and line number, and the message itself. "FileNotFoundError: photos/holiday.jpg" simply means: the program is looking for a file that doesn't exist in that place. The AI can explain any message in plain words.
Asking for the fix properly
Give the AI four things: the complete error message, copied as is; what you were doing when it happened; what you expected; what you've already tried. "When I click Calculate, nothing happens. The console shows: [the message]. I expected the total. I've already reloaded the page."
When the AI goes round in circles
- After two or three failed fixes, go back to the last version that worked instead of piling on patches.
- Ask it to explain the cause before suggesting code: "Where do you think this problem comes from?"
- Beware of fixes that remove the check instead of repairing: switching off a check makes the message disappear, not the problem.
- A new conversation, with a clear summary of the project and the current code, often gets things moving again.
Key takeaways
- Browser console, terminal or log: the message is always somewhere.
- Spot the error type, the file, the line and the message.
- Give the AI the full message, the context, the expected result and what you tried.
- After two or three failures: go back and ask for the cause.
Complete the lesson
A 4-question quiz: 3 correct answers are enough, plus an exercise to practise. It opens in the Academy, on this same lesson.
Take the quiz and complete the lesson Free. With an account, your progress is saved and leads to the course certificate.The course: Coding with AI, even if you're not a developer
- What you can build, and how to describe it9 min
- Small steps, and test every time9 min
- Reading an error and getting it fixed9 min
- What you should never do9 min
- Your first project, from A to Z10 min