Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(kumascript): mention path in render error message (v2) #8953

Merged
merged 3 commits into from
May 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 9 additions & 0 deletions build/blog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ export async function findPostLiveSampleBySlug(
rawBody: body,
metadata: { locale: DEFAULT_LOCALE, ...blogMeta },
isMarkdown: true,
fileInfo: {
path: file,
},
});
return liveSamples.find((page) => page.id.toLowerCase() === id)?.html;
}
Expand All @@ -94,6 +97,9 @@ export async function findPostBySlug(
rawBody: body,
metadata: { locale: DEFAULT_LOCALE, ...blogMeta },
isMarkdown: true,
fileInfo: {
path: file,
},
});
return { doc, blogMeta };
}
Expand Down Expand Up @@ -177,6 +183,9 @@ export async function buildBlogPosts(options: {
rawBody: body,
metadata: { locale, ...blogMeta },
isMarkdown: true,
fileInfo: {
path: file,
},
};
const { doc: builtDoc, liveSamples } = await buildPost(renderDoc);
const { doc } = {
Expand Down
1 change: 1 addition & 0 deletions kumascript/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export async function render(
rawHTML,
{
...metadata,
path: fileInfo?.path,
url,
tags: metadata.tags || [],
selective_mode,
Expand Down
7 changes: 6 additions & 1 deletion kumascript/src/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,12 @@ export default class Templates {
});
return rendered.trim();
} catch (error) {
console.error(`${name} macro failed:`, error);
console.error(
`The ${name} macro in ${
args.env.path ?? args.env.url
} failed to render.`,
error
);
throw error;
}
}
Expand Down