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

amp-script: catch user errors in worker scripts #28207

Merged
merged 2 commits into from
May 6, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions extensions/amp-script/0.1/amp-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,13 @@ export class AmpScript extends AMP.BaseElement {
config
).then((workerDom) => {
this.workerDom_ = workerDom;
this.workerDom_.onerror = (errorEvent) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is workerDom a Worker instance?

Copy link
Member Author

Choose a reason for hiding this comment

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

yep. its...a worker from worker-dom. It would potentially make sense to just name it worker. This is the exact API I plan on changing in ampproject/worker-dom#850

errorEvent.preventDefault();
user().error(
TAG,
`${errorEvent.message}\n at (${errorEvent.filename}:${errorEvent.lineno})`
);
};
});
return workerAndAuthorScripts;
}
Expand Down