Skip to content

Conversation

@jp-knj
Copy link
Member

@jp-knj jp-knj commented May 6, 2025

Changes

  • remove todo comments
  • Replaced generic Error throws with AstroError in packages/astro/src/content/loader/file.ts.
    • Adds contextual error names and messages:
      • Glob Pattern Error for disallowing * in file() loader paths.
      • Parser Not Found when no parser is available for the file extension.
    • Imports AstroError from core/errors so all runtime errors funnel through our unified error-handling layer.
  • Changeset included (pnpm exec changeset) to surface in release notes.

Testing

  • Ran the full test suite: pnpm test – all existing tests pass.
  • Manual sanity check:
    1. Created a sample project with a bad data/*.json glob; verified the new Glob Pattern Error message surfaces in the terminal with the Astro error banner.
    2. Pointed the loader to an .xml file; saw the Parser Not Found message and helpful suggestion.

No additional tests added because logic remains identical; only the error-reporting wrapper changed.

Docs

No user-facing API changes. Docs remain valid.

@changeset-bot
Copy link

changeset-bot bot commented May 6, 2025

🦋 Changeset detected

Latest commit: 4df12d2

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 the pkg: astro Related to the core `astro` package (scope) label May 6, 2025
@jp-knj jp-knj changed the title refactor(astro): Replaced generic Error throws with `AstroError refactor(astro): Replaced generic Error throws with AstroError May 6, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented May 6, 2025

CodSpeed Performance Report

Merging #13759 will not alter performance

Comparing jp-knj:replace-astro-error (4df12d2) with main (63d60c2)

Summary

✅ 6 untouched benchmarks

@jp-knj jp-knj marked this pull request as ready for review May 6, 2025 13:58
Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@ematipico ematipico merged commit 4a56d0a into withastro:main May 6, 2025
5 checks passed
@astrobot-houston astrobot-houston mentioned this pull request May 6, 2025
@florian-lefebvre
Copy link
Member

Hi @jp-knj thanks for the PR! We follow a pattern for errors that is putting them in https://github.com/withastro/astro/blob/main/packages/astro/src/core/errors/errors-data.ts. Would you mind opening another PR for this?

openscript pushed a commit to openscript/astro that referenced this pull request Sep 12, 2025
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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants