fix: MDX errors not having stack trace and a confusing name (#8438)
* fix(mdx): Fix errors having weird names and no stack trace * chore: changeset
This commit is contained in:
parent
eb7615f25a
commit
6df4f3bd9d
2 changed files with 12 additions and 0 deletions
5
.changeset/olive-deers-switch.md
Normal file
5
.changeset/olive-deers-switch.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'@astrojs/mdx': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix errors not having a stacktrace
|
|
@ -153,7 +153,14 @@ export default function mdx(partialMdxOptions: Partial<MdxOptions> = {}): AstroI
|
||||||
};
|
};
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
const err: SSRError = e;
|
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 };
|
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;
|
throw err;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue