Skip to content

fix: include method and path in plain object return error#148

Open
immanuwell wants to merge 1 commit into
tscircuit:mainfrom
immanuwell:main
Open

fix: include method and path in plain object return error#148
immanuwell wants to merge 1 commit into
tscircuit:mainfrom
immanuwell:main

Conversation

@immanuwell
Copy link
Copy Markdown

What

When a route returns a plain object instead of ctx.json({...}), the error message now includes the HTTP method and path so it's immediately clear which route caused the problem.

Before:

Use ctx.json({...}) instead of returning an object directly.

After:

Route GET /api/foo returned a plain object. Use ctx.json({...}) instead of returning an object directly.

Changes

  • src/middleware/with-response-object-check.ts: extract req.method and new URL(req.url).pathname and prepend them to the error message
  • tests/errors/do-not-allow-raw-json.test.ts: add assertion that error includes "Route GET /"

/claim #30

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant