yarkovaleksei / vue2-storage

Wrapper over browser storage for JavaScript or Vue.js app

Home Page:http://yarkovaleksei.github.io/vue2-storage/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Exception Handling

wapacro opened this issue · comments

We recently ran into issues when saving items which are too large or which cause the storage space to exceed the quota in total. Since the set method catches any exceptions and just prints them there is not really an easy way to handle these cases.

It'd therefore be great if the library could just throw the exceptions so the developer has access to it and could handle it using try {} catch(e) {}.

I would be happy to provide another pull request but I quickly wanted to check what implementation you would prefer. In my opinion we could simply add a new setting throwExceptions: true which by default is false. This prevents any breaking changes.

If the setting is true simply throw any exceptions; if not just print it to the console like it's done today. Or would you rather completely switch to throwing exceptions?

It would be better to throw an exception than just writing to the console. Initially, I made a mistake when I did not take this into account. Parameter is not needed. You just need to add error handling.

@wapacro Done in version 5.0.0!

Great, thank you @yarkovaleksei 😄