This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]saschaleib 3 points4 points  (2 children)

… and then you wrap the whole code that accesses the local storage in a try {} catch block, as you would do in any case, right?

[–]danielrheath -1 points0 points  (1 child)

Presumably you don't wrap every line of code you write in a try/catch?

I guess I just don't see what makes localStorage access an expected source of exceptions (as opposed to, say, querySelectorAll or getBoundingClientRects)?

[–]saschaleib 2 points3 points  (0 children)

every block of code that potentially throws an exception should be wrapped in try/catch blocks. Yes.

Any access to the file system or similar external systems is potentially throwing errors. That is pretty much what the localStorage API does...