-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
add expectedError method #6581
Conversation
da3b87c
to
52460dd
Compare
expectedError(tag, var_args) { | ||
const error = this.error(tag, var_args); | ||
if (error) { | ||
error.expected = true; |
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.
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?
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.
yeah i can do that, that was actually the original code i had written.
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.
done.
52460dd
to
4bc5a5f
Compare
@dvoytenko changes made. PTAL |
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.
Can we add #expectedError
calls to xhr-impl.js
and amp-accordion.js
, too?
*/ | ||
error(tag, var_args) { | ||
error_(tag, var_args) { |
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.
Mark private.
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.
done.
expectedError(tag, var_args) { | ||
const error = this.error_.apply(this, arguments); | ||
if (error) { | ||
error.expected = true; | ||
this.win.setTimeout(() => {throw error;}); |
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.
Don't we have a rethrowAsync
?
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.
yeah, i think it calls createErrorVarArgs again though
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.
👍
@jridgewell can you point out to me what the expectedError is in xhr? |
Ping. |
@jridgewell sorry bout that, will finish this today. got caught up in this other issue |
ac0dc33
to
5ec84cb
Compare
@@ -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'); |
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.
@dvoytenko can you review this?
}; | ||
xhr.onabort = () => { | ||
reject(new Error('Request aborted')); | ||
reject(user().createExpectedError('Request aborted')); |
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.
@dvoytenko please review
5ec84cb
to
9062274
Compare
9062274
to
a4a008e
Compare
a4a008e
to
d1f3715
Compare
* add expectedError method * add private helper method and tests * add private annotation * add createExpectedError method and fix xhr-impl
* add expectedError method * add private helper method and tests * add private annotation * add createExpectedError method and fix xhr-impl
* add expectedError method * add private helper method and tests * add private annotation * add createExpectedError method and fix xhr-impl
No description provided.