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 = {}): 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; } },