Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(astro): handle optional js-yaml error marks
  • Loading branch information
florian-lefebvre committed Sep 23, 2026
commit c960fe0dadd26018ee3a2304066187455d8dc629
12 changes: 7 additions & 5 deletions packages/astro/src/content/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,11 +462,13 @@ export function safeParseFrontmatter(source: string, id?: string) {
});

if (isYAMLException(err)) {
markdownError.setLocation({
file: id,
line: err.mark.line,
column: err.mark.column,
});
if (err.mark) {
markdownError.setLocation({
file: id,
line: err.mark.line,
column: err.mark.column,
});
}

markdownError.setMessage(err.reason);
}
Expand Down
7 changes: 5 additions & 2 deletions packages/astro/src/core/errors/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,13 @@ export function isYAMLException(err: unknown): err is YAMLException {

/** Format YAML exceptions as Vite errors */
export function formatYAMLException(e: YAMLException): ViteErrorPayload['err'] {
const mark = e.mark;
return {
name: e.name,
id: e.mark.name,
loc: { file: e.mark.name, line: e.mark.line + 1, column: e.mark.column },
id: mark?.name ?? undefined,
loc: mark
? { file: mark.name ?? undefined, line: mark.line + 1, column: mark.column }
: undefined,
message: e.reason,
stack: e.stack ?? '',
};
Expand Down
Loading
⌂ 换网址