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(gatsby-plugin-mdx): display better error message for MDX html field in development #19111

Merged
merged 1 commit into from
Oct 29, 2019
Merged
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
3 changes: 2 additions & 1 deletion packages/gatsby-plugin-mdx/gatsby/source-nodes.js
Original file line number Diff line number Diff line change
@@ -184,7 +184,8 @@ module.exports = (
return html
} catch (e) {
reporter.error(
`Error querying the \`html\` field. This field is intended for use with RSS feed generation.
`gatsby-plugin-mdx: Error querying the \`html\` field.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pieh Shouldn't reporter.error already mention the plugin it was called in?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind. It will only after #19024 is resolved

This is okay for now

This field is intended for use with RSS feed generation.
If you're trying to use it in application-level code, try querying for \`Mdx.body\` instead.
Original error:
${e}`
5 changes: 2 additions & 3 deletions packages/gatsby-plugin-mdx/utils/render-html.js
Original file line number Diff line number Diff line change
@@ -155,9 +155,8 @@ exports.mdxHTMLLoader = ({ cache, reporter, store }) =>
keys.map(({ body }) =>
renderMdxBody
? renderMdxBody(body)
: reporter.error(
`gatsby-plugin-mdx: renderMdxBody was unavailable when rendering html.
>> This is a bug.`
: new Error(
`renderMdxBody was unavailable when rendering html.`
)
)
)