Closed webJose closed 11 months ago
My preference is to only catch
when there is something that can be done about it.
For situations where errors are expected and custom serializer
can be passed.
Things can be done. The ideal scenario would be to run an onError handler and let the consumer of the store to determine what to do.
onError
, (just as validate
in my other issue) would be passed as options.
This way the consumer of the value will be assured that any malformations will be notified through this mechanism.
Because your application may have 1000 entry points that could trigger reading the malformed value. Are we going to write try..catch everywhere? No. We would most likely have to introduce a proxy of some kind.
I understand, but I want to be careful about how many options this repo provides. The more that is added, the more docs are needed and it brings more complexity for an super edge case.
Feel free to fork and add any edge cases you need.
The call to
serializer.parse()
should be inside atry..catch
. Users may directly tamper with stored values which might cause errors while parsing.