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
🐛 Add error messages to thrown bare Error()s in amp-script
#28185
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this result in two console messages for a single error? Might be better to catch these errors which would prevent them from showing up in the error reporter due to unhandled rejection.
Indeed it does! Currently the page logs one useful/informative error, followed by two completely empty errors: These changes would fix the blank error messages to be more informative, making it clear the error is the same.
The first More generally, I definitely agree errors in publishers' custom amp-script code should be caught and not logged to error reporting, but that felt out-of-scope for this PR. I imagine you'd prefer to see the underlying issues here (#24266 and #27904) actually fixed, which this PR does not do. My objective with this PR was more of a small step forward, adding more information to both the console and error reporting, while the underlying issues are explored and addressed Edit: Filed new issue #28198 for tracking handling of amp-script errors in publisher code |
So I think the error string extraction hasn't launched yet anyways, so we can ignore the "use %s" guidance for now and just use JS template literals. I.e. make the new thrown Thanks for fixing this. /cc @ampproject/wg-performance |
SGTM! |
/cc @rsimha |
@rcebulko, thanks for alerting me. Codecov is choosing a base commit that's 4 days old because your branch was forked from https://travis-ci.org/github/ampproject/amphtml/jobs/683465296 I'll look into manually setting the base commit to |
…ect#28185) * Add error messages to thrown bare Error()s * Throw errors with string template literals
As part of #24266, error messages with substitutions aren't logged properly. Some parts of amp-script use
user().error()
to log locally, thenthrow new Error()
, resulting in AMP Error Reporting getting a smattering of bareError: Error
reports, which add to error reporting noise and are difficult for a release on-duty to assess/debugThis PR updates those bare
throw
s to instead throw a user error with a useful message.Closes #28184