-
Notifications
You must be signed in to change notification settings - Fork 68
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 onerror example #439
Add onerror example #439
Conversation
7d6e854
to
6ecdef4
Compare
Let's wait for @reillyeon to review before merging. |
index.html
Outdated
reader.scan().then(() => { | ||
console.log("Scan started successfully."); | ||
reader.onerror = event => { | ||
console.log("Error! Cannot read data from NFC tag."); |
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.
The log message below says "try again" but this case is really the one were retrying makes sense (tell the user to hold their device against the tag for longer) whereas an error below indicates a more fatal issue.
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.
The onerror event is raised only for IOException
and FormatException
, not TagLostException
. I believe* this means holding device longer won't change anything. Both are fatal errors.
Do you want to me remove "try again" to make it clearer?
Throws | Reason |
---|---|
TagLostException | if the tag leaves the field |
IOException | if there is an I/O failure, or the operation is canceled |
FormatException | if the NDEF Message on the tag is malformed |
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.
Interesting. Do you think we should fire an event on TagLostException
? That seems like the most likely and most actionable error that a site could encounter.
Given the current behavior I would word the error as, "Error! Cannot read data from the NFC tag. Try a different one?"
My goal is for this example code to demonstrate to developers what parts of their UI should be responding to different events, and how. This also gives us a good opportunity to test whether or not developers will be able to easily code against these potential errors.
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.
I don't think TagLostException
provides that much value as users will try again if they see app is not reacting, while IOException
and FormatException
are more "It's over" errors. They're nothing users can do about it as they use wrong formatted tags, and website will only show them something like "Sorry! This tag is not compatible with this application".
I'll update my example with your error message.
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.
See c5109bc
This PR addresses comment posted by @reillyeon in #432 (comment)
Preview | Diff