code_error_context
code_error_context returns the code around a given file and line number. It is designed for use when a build or test failure reports a specific location — paste the file and line in, get the relevant code back without reading the whole file.
code_error_context(file="src/services/payment.ts", line=42)Parameters
Section titled “Parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
file | string | required | Path to the file containing the error |
line | number | required | Line number reported in the error |
Output
Section titled “Output”src/services/payment.ts — around line 42
39: const result = await stripe.charges.create({ 40: amount: order.total, 41: currency: 'usd',→ 42: source: card.token, // ← error here 43: idempotency_key: key, 44: });When to use
Section titled “When to use”- A compiler or runtime error reports a file and line number
- A test failure points to a specific assertion
- You want context around a log line without loading the entire file
Workflow with code_build
Section titled “Workflow with code_build”code_build()→ error[E0308] at src/services/payment.ts:42
code_error_context(file="src/services/payment.ts", line=42)→ Shows code around line 42
code_get(name="PaymentService.charge")→ Full function if you need more context