Skip to content

add expectedError method#6581

Merged
erwinmombay merged 4 commits intoampproject:masterfrom
erwinmombay:log-update
Dec 20, 2016
Merged

add expectedError method#6581
erwinmombay merged 4 commits intoampproject:masterfrom
erwinmombay:log-update

Conversation

@erwinmombay
Copy link
Copy Markdown
Member

No description provided.

expectedError(tag, var_args) {
const error = this.error(tag, var_args);
if (error) {
error.expected = true;
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member Author

@dvoytenko changes made. PTAL

Copy link
Copy Markdown
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?

* @return {!Error|undefined}
*/
error(tag, var_args) {
error_(tag, var_args) {
Copy link
Copy Markdown
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
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

done.

src/log.js Outdated
const error = this.error_.apply(this, arguments);
if (error) {
error.expected = true;
this.win.setTimeout(() => {throw error;});
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

@erwinmombay
Copy link
Copy Markdown
Member Author

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

@jridgewell
Copy link
Copy Markdown
Contributor

Ping.

@erwinmombay
Copy link
Copy Markdown
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
xhr.open(method, url);
} else {
throw new Error('CORS is not supported');
throw dev().createExpectedError('CORS is not supported');
Copy link
Copy Markdown
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
Copy Markdown
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