diff options
-rw-r--r-- | .changeset/hot-games-doubt.md | 5 | ||||
-rw-r--r-- | packages/astro/src/vite-plugin-astro-server/plugin.ts | 10 |
2 files changed, 11 insertions, 4 deletions
diff --git a/.changeset/hot-games-doubt.md b/.changeset/hot-games-doubt.md new file mode 100644 index 000000000..8ed8005b1 --- /dev/null +++ b/.changeset/hot-games-doubt.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes a bug in error handling that saving a content file with a schema error would display an "unhandled rejection" error instead of the correct schema error diff --git a/packages/astro/src/vite-plugin-astro-server/plugin.ts b/packages/astro/src/vite-plugin-astro-server/plugin.ts index 180e122e8..bed0069b6 100644 --- a/packages/astro/src/vite-plugin-astro-server/plugin.ts +++ b/packages/astro/src/vite-plugin-astro-server/plugin.ts @@ -92,10 +92,12 @@ export default function createVitePluginAstroServer({ viteServer.watcher.on('change', rebuildManifest); function handleUnhandledRejection(rejection: any) { - const error = new AstroError({ - ...AstroErrorData.UnhandledRejection, - message: AstroErrorData.UnhandledRejection.message(rejection?.stack || rejection), - }); + const error = AstroError.is(rejection) + ? rejection + : new AstroError({ + ...AstroErrorData.UnhandledRejection, + message: AstroErrorData.UnhandledRejection.message(rejection?.stack || rejection), + }); const store = localStorage.getStore(); if (store instanceof IncomingMessage) { const request = store; |