Explain This Error with Ranked Causes

Explains an error and stack trace in plain words, ranks the three most likely causes and gives a confirming check for each.

You get: A text answer

More like this

Ready to use: no blanks to fill in.

The prompt

explain-this-error-with-ranked-causes.md
You are a patient senior developer helping me understand an error. Here is the error message and stack trace: {paste your error message and stack trace here}. If you cannot tell the language, runtime version, or what I was doing when it happened, ask me up to two short questions first. Rules: read the stack trace from the first frame in my own code, not the deepest frame; separate what the trace proves from what you are guessing; give causes that are specific to this trace, not generic advice; make each check something I can run in under five minutes. Output format: 1) Plain-words explanation in three sentences or fewer. 2) The three most likely causes, ranked, each with a likelihood (high, medium or low), the evidence from the trace, and one check that confirms or rules it out, such as a command, log line or code snippet. 3) What the result of each check means and the fix that follows. 4) Missing information that would sharpen the ranking. 5) Next action: which check to run first and why. The answer is good if I can act without further searching.

Example output

AI-written example

1) Plain-words explanation
Line 42 of orders.js calls .map() on a value that is undefined, so JavaScript can't read map from it. The value reached formatOrders empty, so the bug is upstream of the .map() call. The trace shows this was triggered from the route handler at routes/orders.js:18.

2) Likely causes, ranked

A. High: the data object has a different shape than expected (e.g. result.orders doesn't exist).

  • Evidence: the trace proves the value is undefined at services/orders.js:42:23. It doesn't prove why. A renamed field or changed query result is the most common reason.
  • Check: add console.log(JSON.stringify(input, null, 2)) on the line before 42 and hit the endpoint once.

B. Medium: the route passes the wrong or missing argument.

  • Evidence: getOrderSummary at routes/orders.js:18 is the only caller in the trace.
  • Check: log typeof the argument on line 18, right before the formatOrders(...) call.

C. Low: an earlier database or API call failed silently and returned nothing.

  • Evidence: this is a guess. The trace shows no error before line 42, which fits a swallowed error.
  • Check: run grep -n "catch" src/routes/orders.js src/services/orders.js and look for a catch that doesn't rethrow or return a value.

3) What each result means

  • A: If the log shows data under another key (say rows or data.orders), fix the property name. If it prints undefined, move to B.
  • B: If the logged type is "undefined", the call site is wrong. Check for a typo or a bad destructure such as const { orders } = req.query. Pass the right value, and add if (!Array.isArray(orders)) throw new Error("orders missing") at the top of formatOrders.
  • C: If you find a silent catch, rethrow the error or return a 500. Then the real failure, such as a connection or SQL problem, will show up in your logs.

4) Missing information

  • Node version and whether the code is TypeScript or plain JavaScript.
  • The code for orders.js lines 35–45 and routes/orders.js lines 10–20.
  • Whether this happens on every request or only for some users or inputs.
  • Whether anything changed recently, such as a schema change or dependency bump.

5) Next action
Run check A first. It tak

Generated from this prompt by AI. Your results will vary.

Tips and common edits

Use when you hit an error you do not understand. Paste the full message and stack trace, and add recent changes or the command you ran if you can.

Questions about this prompt

More in Coding

Failing Test First Bug Fix

Reproduces a bug with a failing test, finds the root cause, applies the smallest fix and shows the test passing.

Architecture Decision Record for a Technology Choice

Compares realistic options against your constraints and produces a decision record. The record has a weighted comparison, risks, a reversal plan, and a recommendation the team can approve or challenge.

Regex with Match and Non-Match Test Strings

Writes a regex for your pattern, explains each part and provides 8 strings that should match and 8 that should not.

Root Cause Analysis from Stack Trace and Logs

Turns an error report, stack trace, and logs into ranked root-cause hypotheses. Includes the cheapest checks to confirm each one, a fix proposal, and a regression test plan.

SQL Query from Schema and Question

Writes a SQL query that answers your question from your schema, explains each clause and suggests indexes worth adding.

Characterization Tests Before a Refactor

Writes tests that lock in a module's current behavior, including edge cases and quirks, so you can refactor safely.

Codebase Tour for a Specific Task

Explores a repo through the lens of your task and explains the architecture, key files and data flow, then says where to start.

Operations Bottleneck Diagnosis and 30-Day Process Fix Plan

Diagnoses where a workflow slows down using your process steps and metrics, then ranks causes and produces a 30-day improvement plan with owners, measures, and risks.

Debug an Error From the Message and the Code Around It

Finds the most likely cause of an error from the message and the relevant code, ranks other possible causes, and gives the smallest fix plus a way to prove it worked.

Pull Request Review with Merge Recommendation

Reviews a diff against your standards and returns a merge, merge-with-changes, or do-not-merge recommendation. Findings are ranked by severity, with evidence, suggested fixes, and open questions.

Unit Test Plan and Test Code for an Existing Function

Builds a behavior-based test matrix for a function or module and then generates test code in your framework. Covers edge cases, failures, and mocking boundaries, with coverage gaps stated honestly.

Trending

Developmental Edit Memo for an Essay Draft With Revise-or-Cut Decisions

Gives a draft essay a structured developmental edit: thesis check, paragraph-by-paragraph audit, and a prioritized revision plan so you can decide what to keep, rewrite, or cut before line editing.