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

add expectedError method #6581

Merged
merged 4 commits into from
Dec 20, 2016
Merged

Conversation

erwinmombay
Copy link
Member

No description provided.

expectedError(tag, var_args) {
const error = this.error(tag, var_args);
if (error) {
error.expected = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

While correct, it's a bit weird to set flag on an error after it's been reported. Maybe better refactor call into a private method and call from both methods with different flags?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah i can do that, that was actually the original code i had written.

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

@erwinmombay
Copy link
Member Author

@dvoytenko changes made. PTAL

Copy link
Contributor

@jridgewell jridgewell left a comment

Choose a reason for hiding this comment

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

Can we add #expectedError calls to xhr-impl.js and amp-accordion.js, too?

*/
error(tag, var_args) {
error_(tag, var_args) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Mark private.

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

expectedError(tag, var_args) {
const error = this.error_.apply(this, arguments);
if (error) {
error.expected = true;
this.win.setTimeout(() => {throw error;});
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't we have a rethrowAsync?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, i think it calls createErrorVarArgs again though

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@erwinmombay
Copy link
Member Author

@jridgewell can you point out to me what the expectedError is in xhr?

@jridgewell
Copy link
Contributor

Ping.

@erwinmombay
Copy link
Member Author

@jridgewell sorry bout that, will finish this today. got caught up in this other issue

@erwinmombay erwinmombay force-pushed the log-update branch 2 times, most recently from ac0dc33 to 5ec84cb Compare December 16, 2016 22:35
@@ -394,7 +394,7 @@ function createXhrRequest(method, url) {
xhr = new XDomainRequest();
xhr.open(method, url);
} else {
throw new Error('CORS is not supported');
throw dev().createExpectedError('CORS is not supported');
Copy link
Member Author

Choose a reason for hiding this comment

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

@dvoytenko can you review this?

};
xhr.onabort = () => {
reject(new Error('Request aborted'));
reject(user().createExpectedError('Request aborted'));
Copy link
Member Author

Choose a reason for hiding this comment

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

@dvoytenko please review

@erwinmombay erwinmombay merged commit a1016c1 into ampproject:master Dec 20, 2016
Lith pushed a commit to Lith/amphtml that referenced this pull request Dec 22, 2016
* add expectedError method

* add private helper method and tests

* add private annotation

* add createExpectedError method and fix xhr-impl
Lith pushed a commit to Lith/amphtml that referenced this pull request Dec 22, 2016
* add expectedError method

* add private helper method and tests

* add private annotation

* add createExpectedError method and fix xhr-impl
torch2424 pushed a commit to torch2424/amphtml that referenced this pull request Jan 3, 2017
* add expectedError method

* add private helper method and tests

* add private annotation

* add createExpectedError method and fix xhr-impl
This was referenced Dec 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants