summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.changeset/brave-pots-listen.md5
-rw-r--r--packages/astro/src/jsx/server.ts4
2 files changed, 8 insertions, 1 deletions
diff --git a/.changeset/brave-pots-listen.md b/.changeset/brave-pots-listen.md
new file mode 100644
index 000000000..bc6d58963
--- /dev/null
+++ b/.changeset/brave-pots-listen.md
@@ -0,0 +1,5 @@
+---
+"astro": patch
+---
+
+Improves DX by throwing the original `AstroUserError` when an error is thrown inside a `.mdx` file.
diff --git a/packages/astro/src/jsx/server.ts b/packages/astro/src/jsx/server.ts
index 2ed308c37..be55b0194 100644
--- a/packages/astro/src/jsx/server.ts
+++ b/packages/astro/src/jsx/server.ts
@@ -1,4 +1,4 @@
-import { AstroError } from '../core/errors/errors.js';
+import { AstroError, AstroUserError } from '../core/errors/errors.js';
import { AstroJSX, jsx } from '../jsx-runtime/index.js';
import { renderJSX } from '../runtime/server/jsx.js';
@@ -52,6 +52,8 @@ function throwEnhancedErrorIfMdxComponent(error: Error, Component: any) {
// if the exception is from an mdx component
// throw an error
if (Component[Symbol.for('mdx-component')]) {
+ // if it's an AstroUserError, we don't need to re-throw, keep the original hint
+ if (AstroUserError.is(error)) return;
throw new AstroError({
message: error.message,
title: error.name,