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(macro): make smartLink() error message more informative #11042

Merged
merged 1 commit into from
May 2, 2024

Conversation

OnkarRuikar
Copy link
Contributor

@OnkarRuikar OnkarRuikar commented May 1, 2024

Summary

For sidebar macros, if there is a bad URL used, then the smartLink function throws a confusing flaw: Error: wrong xref macro used (consider changing which macro you use). This doesn't give much information about the buggy URL.

Also, the printed stack trace doesn't help in this situation to narrow down the location. Stack trace code line numbers are not the same because .ts file gets converted to .js.

Error: Wrong xref macro used (consider changing which macro you use).
    at Object.recordNonFatalError (file:///home/onkar/GitHub/mdn/content/node_modules/@mdn/yari/kumascript/src/render.js:90:23)
    at Object.smartLink (file:///home/onkar/GitHub/mdn/content/node_modules/@mdn/yari/kumascript/src/api/web.js:93:37)
    at renderSubsection ("/home/onkar/GitHub/mdn/content/node_modules/@mdn/yari/kumascript/macros/AccessibilitySidebar.ejs":101:26)
    at renderSection ("/home/onkar/GitHub/mdn/content/node_modules/@mdn/yari/kumascript/macros/AccessibilitySidebar.ejs":130:21)
    at renderSidebar ("/home/onkar/GitHub/mdn/content/node_modules/@mdn/yari/kumascript/macros/AccessibilitySidebar.ejs":140:21)
    at async eval ("/home/onkar/GitHub/mdn/content/node_modules/@mdn/yari/kumascript/macros/AccessibilitySidebar.ejs":148:16)
    at async Templates.render (file:///home/onkar/GitHub/mdn/content/node_modules/@mdn/yari/kumascript/src/templates.js:94:30)
    at async render (file:///home/onkar/GitHub/mdn/content/node_modules/@mdn/yari/kumascript/src/render.js:192:40)
    at async Module.render (file:///home/onkar/GitHub/mdn/content/node_modules/@mdn/yari/kumascript/index.js:58:36)
    at async buildDocument (file:///home/onkar/GitHub/mdn/content/node_modules/@mdn/yari/build/index.js:160:42)

Solution

In the error message log path sent to the smartLink function. This will help sidebar macro maintainers to quickly figure out erroneous paths.


Before

The macro throws a confusing flaw: Error: wrong xref macro used (consider changing which macro you use)

After

Explanation: Wrong xref macro used (consider changing which macro you use). Error processing path /en-US/docs/Web/Accessibility/ARIA/Annotations

How did you test this change?

In local dev environment reproduced #11040 issue and tested output before and after the fix.

@OnkarRuikar OnkarRuikar requested a review from a team as a code owner May 1, 2024 04:48
@github-actions github-actions bot added the macros tracking issues related to kumascript macros label May 1, 2024
@caugner caugner merged commit 930c9cf into mdn:main May 2, 2024
9 checks passed
@OnkarRuikar OnkarRuikar deleted the fix_smartlink branch May 3, 2024 02:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
macros tracking issues related to kumascript macros
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants