summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.changeset/olive-deers-switch.md5
-rw-r--r--packages/integrations/mdx/src/index.ts7
2 files changed, 12 insertions, 0 deletions
diff --git a/.changeset/olive-deers-switch.md b/.changeset/olive-deers-switch.md
new file mode 100644
index 000000000..84cba951a
--- /dev/null
+++ b/.changeset/olive-deers-switch.md
@@ -0,0 +1,5 @@
+---
+'@astrojs/mdx': patch
+---
+
+Fix errors not having a stacktrace
diff --git a/packages/integrations/mdx/src/index.ts b/packages/integrations/mdx/src/index.ts
index 9053e824c..c27abb4d1 100644
--- a/packages/integrations/mdx/src/index.ts
+++ b/packages/integrations/mdx/src/index.ts
@@ -153,7 +153,14 @@ export default function mdx(partialMdxOptions: Partial<MdxOptions> = {}): AstroI
};
} catch (e: any) {
const err: SSRError = e;
+
+ // For some reason MDX puts the error location in the error's name, not very useful for us.
+ err.name = 'MDXError';
err.loc = { file: fileId, line: e.line, column: e.column };
+
+ // For another some reason, MDX doesn't include a stack trace. Weird
+ Error.captureStackTrace(err);
+
throw err;
}
},