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

Refactor and trap localStorage and JSON parsing errors #48

Merged
merged 6 commits into from
Jul 28, 2020

Conversation

tbcd
Copy link
Contributor

@tbcd tbcd commented Jul 20, 2020

The main reason for this PR is to trap exceptions being thrown by localStorage (of which there are many weird cases across different platforms and browsers), and JSON.parse().

Exceptions are logged to the console as warnings, by default, re-using disableWarnings to silence them. This means that disableWarnings is now needed as an option for save() and clear() as well.

Also includes some trivial refactoring in digestible small commits that steer toward the final commit.

@kilkelly kilkelly merged commit 609afb3 into kilkelly:master Jul 28, 2020
@kilkelly
Copy link
Owner

Thanks @tbcd , great pull request 💯 Sorry for the delay in merging it!

@tbcd
Copy link
Contributor Author

tbcd commented Jul 30, 2020

No problem at all. There was quite a bit more in this one than the others so I expected it to take more time, assuming you had actually wanted it.. as it did come out of the blue. :)

I didn't mark this PR as fixing #23 because that was requesting something a bit different, but these changes may be similar enough to close that issue anyway.

@tbcd tbcd deleted the refactor-and-trap-errors branch July 30, 2020 15:03
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.

None yet

2 participants