mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
Fix throw AstroUserError
in mdx (#11192)
* fix: throw original AstroUserError in mdx * add changeset * Update brave-pots-listen.md Co-authored-by: Emanuele Stoppa <my.burning@gmail.com> --------- Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
This commit is contained in:
parent
4ad1ce24e1
commit
58b10a0731
2 changed files with 8 additions and 1 deletions
5
.changeset/brave-pots-listen.md
Normal file
5
.changeset/brave-pots-listen.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"astro": patch
|
||||
---
|
||||
|
||||
Improves DX by throwing the original `AstroUserError` when an error is thrown inside a `.mdx` file.
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue