Skip to content

Commit

Permalink
fix: improve error message when a middleware doesn't return a `Respon…
Browse files Browse the repository at this point in the history
…se` (#9434)

* fix: improve error message when a middleware doesn't return a `Response`

* Apply suggestions from code review

Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>

* fix typo

---------

Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
  • Loading branch information
ematipico and sarah11918 authored Dec 15, 2023
1 parent fcc2fd5 commit c01580a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/selfish-parents-leave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Improves the error message when a middleware doesn't return a `Response`
5 changes: 3 additions & 2 deletions packages/astro/src/core/errors/errors-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -733,8 +733,9 @@ export const ResponseSentError = {
*/
export const MiddlewareNoDataOrNextCalled = {
name: 'MiddlewareNoDataOrNextCalled',
title: "The middleware didn't return a response or call `next`.",
message: 'The middleware needs to either return a `Response` object or call the `next` function.',
title: "The middleware didn't return a `Response`.",
message:
'Make sure your middleware returns a `Response` object, either directly or by returning the `Response` from calling the `next` function.',
} satisfies ErrorData;

/**
Expand Down

0 comments on commit c01580a

Please sign in to comment.