Skip to content

Commit 9838049

Browse files
fix(errors): add a message to the redirect error and a hint to the rewrite error (#17960)
1 parent 8ae6b46 commit 9838049

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

‎.changeset/quiet-owls-explain.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
Improves the diagnostics of some Astro errors.

‎packages/astro/src/core/errors/errors-data.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,6 +1040,8 @@ export const AstroGlobNoMatch = {
10401040
export const RedirectWithNoLocation = {
10411041
name: 'RedirectWithNoLocation',
10421042
title: 'A redirect must be given a location with the `Location` header.',
1043+
message:
1044+
'The redirect `Response` has no `Location` header. Use `Astro.redirect()` to create redirects, or add a `Location` header to the `Response`.',
10431045
} satisfies ErrorData;
10441046

10451047
/**
@@ -1398,6 +1400,7 @@ export const RewriteWithBodyUsed = {
13981400
title: 'Cannot use `Astro.rewrite()` after the request body has been read.',
13991401
message:
14001402
'`Astro.rewrite()` cannot be used if the request body has already been read. If you need to read the body, first clone the request.',
1403+
hint: 'Read the body from `Astro.request.clone()` instead of `Astro.request`, so the original request can still be rewritten.',
14011404
} satisfies ErrorData;
14021405

14031406
/**

0 commit comments

Comments
 (0)