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

Log if slide index is not a number #8982

Merged
merged 5 commits into from Apr 28, 2017
Merged

Conversation

camelburrito
Copy link
Contributor

@camelburrito camelburrito commented Apr 27, 2017

Investigation logging for #8920

@@ -493,7 +493,7 @@ export class AmpSlideScroll extends BaseSlides {
*/
showSlideWhenReady_(value) {
const index = parseInt(value, 10);
if (isFinite(index)) {
if (isFinite(index) && index > 0 && index < this.noOfSlides_) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't the index be 0?

Further: is this error comes from predefined use case, such as swiping or auto-advance/loop? Or from user-defined user action (on action). If on-action - this should probably be user().error() if from predefined behavior - it should probably be a dev.error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -514,6 +514,7 @@ export class AmpSlideScroll extends BaseSlides {
*/
showSlide_(newIndex) {
const noOfSlides_ = this.noOfSlides_;
newIndex = dev().assertNumber(newIndex);
Copy link
Contributor

Choose a reason for hiding this comment

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

To clarify: dev.assertNumber is stripped in PROD binary. Is this what you want?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@camelburrito
Copy link
Contributor Author

PTAL

const newSlideInView = this.slides_[newIndex];

if (newSlideInView === undefined) {
dev.error(
Copy link
Contributor

Choose a reason for hiding this comment

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

It should be dev(), right?

if (newSlideInView === undefined) {
dev.error(
TAG,
'Accessing a non-existant slide at index: %s, noOfSlides: %s',
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think errors support %s format, unfortunately. It's also best to construct an error with a non-var message and instead pass arguments in Error.args map.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry about that i blindly converted from one method to another , fixed it now - also added a return; (since we are logging this.)

@camelburrito
Copy link
Contributor Author

PTAL

@camelburrito camelburrito merged commit be6da22 into ampproject:master Apr 28, 2017
mrjoro pushed a commit to mrjoro/amphtml that referenced this pull request Apr 28, 2017
* Log if slide index is not a number

* Review changes

* Review changes

* Fixing tests

* lint
@camelburrito camelburrito deleted the p1 branch April 28, 2017 22:59
KenneyE pushed a commit to spotxchange/amphtml that referenced this pull request May 3, 2017
* Log if slide index is not a number

* Review changes

* Review changes

* Fixing tests

* lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants