Skip to content

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)
ParameterTypeDefaultDescription
filestringrequiredPath to the file containing the error
linenumberrequiredLine number reported in the error
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: });
  • 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
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