Skip to content
AI Stack Nest
IntermediateLesson 2 of 7 · 2 min read

Reading Error Messages with AI

Pasting an error message and its context into an AI assistant can cut debugging time significantly, especially for unfamiliar errors.

Error messages range from perfectly descriptive to completely opaque. An AI assistant can read them quickly and suggest causes, which is especially useful when you are working in a language or framework you are still learning.

How to paste an error for best results

Include both the error message and the code that produced it. The error alone is usually not enough. Add a one-sentence description of what you were trying to do when the error appeared.

If the error involves a specific line, paste that function or block along with the line, not just the line in isolation. Context matters. The assistant needs to see the shape of what you were doing.

What the assistant is good at here

Pattern recognition: many errors have common causes and the assistant has seen them many times. Stack overflow in a recursive function, null pointer in an object access chain, type mismatch in a function call. These get quick, accurate suggestions.

Explaining what the error message actually means in plain language. This is useful for dense compiler messages or framework-specific errors with obscure wording.

What it struggles with

Intermittent bugs that depend on runtime state the assistant cannot see. Race conditions, timing-dependent failures, bugs that only appear with certain data. For these, describe the symptoms carefully and treat suggestions as hypotheses to test, not solutions.

A concrete example

A developer gets a TypeError in a JavaScript function. They paste the error and the function into the assistant with the note: "This runs fine most of the time but throws this error when the input is null." The assistant immediately flags the missing null check at the start of the function and suggests where to add it. The fix takes thirty seconds.

code: | function getFirstItem(arr) { // Bug: no null check return arr[0].name; } // Fixed version: function getFirstItemSafe(arr) { if (!arr || arr.length === 0) return null; return arr[0].name; } console.log(getFirstItemSafe(null)); console.log(getFirstItemSafe([{name: "first"}])); codeOutput: "null\nfirst" canRun: true

Try it

The next time you hit an error that takes more than two minutes to understand, paste the message and the relevant code into an AI assistant. Add one sentence of context about what you were trying to do. Use the response to understand the cause, not just apply the fix.

Quick check

What context should you always include when asking AI to help debug an error?

Quick check

What should you do with the AI's suggested fix?

Quick check

When is AI least helpful for debugging?

0 of 7 lessons done in this track