Skip to content

fix: bubble up errors in rewrites#11136

Merged
ematipico merged 5 commits intomainfrom
fix/bubble-up-error
Jun 5, 2024
Merged

fix: bubble up errors in rewrites#11136
ematipico merged 5 commits intomainfrom
fix/bubble-up-error

Conversation

@ematipico
Copy link
Copy Markdown
Member

@ematipico ematipico commented May 24, 2024

Changes

Closes #11110

Two important changes here:

  • inside the RenderContext, I removed the try/catch inside the rewrite method. Now runtime errors emitted by that function are bubbled up and shown to the user
  • removed the possibility of using Astro.rewrite("/404") inside static pages. It doesn't make sense to emit HTML/static pages that contain the HTML of a 404 without returning a Response with status code 404. However, this is still a valid behaviour in SSR because we're able to return a Response with the correct status code. In order to align this behaviour, I added a new abstract method inside the base pipeline. In dev, we allow this behaviour only if the configuration is in SSR, so the user receives a similar DX to SSR.

Testing

I updated some existing test cases. I created a new fixture to make sure that building a SSG project, and using Astro.rewrite("/404") throws an error.

Docs

N/A

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented May 24, 2024

🦋 Changeset detected

Latest commit: 2d9aefd

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added pkg: astro Related to the core `astro` package (scope) pr: docs A PR that includes documentation for review labels May 24, 2024
@ematipico ematipico force-pushed the fix/bubble-up-error branch 2 times, most recently from 9f2729d to 2803dfe Compare June 5, 2024 10:09
@ematipico ematipico requested review from a team June 5, 2024 10:10
@ematipico ematipico force-pushed the fix/bubble-up-error branch from 2803dfe to 4a8698a Compare June 5, 2024 10:27
@ematipico ematipico force-pushed the fix/bubble-up-error branch from 4a8698a to 1d22289 Compare June 5, 2024 12:09
@ematipico ematipico force-pushed the fix/bubble-up-error branch from 1d22289 to 2d9aefd Compare June 5, 2024 12:09
@ematipico ematipico merged commit 35ef53c into main Jun 5, 2024
@ematipico ematipico deleted the fix/bubble-up-error branch June 5, 2024 12:09
@astrobot-houston astrobot-houston mentioned this pull request Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: astro Related to the core `astro` package (scope) pr: docs A PR that includes documentation for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expertimental rewrite: when target page throws an error, this results in "404 Not Found"

2 participants