pinia-plugin-persistedstate
pinia-plugin-persistedstate copied to clipboard
Add error message printing
It is necessary to print the error message. Pinia-plugin-persistedstate failed to write to the localstorage because of the hidden object circular reference, but there is no error message on the console. It took me one day to find the cause.😂
Description
It is necessary to print the error message. Pinia-plugin-persistedstate failed to write to the localstorage because of the hidden object circular reference, but there is no error message on the console. It took me one day to find the cause.😂
Linked Issues
Additional context
I do appreciate the idea, but I think logging errors like this needs to happen only when specified to do so. Logging in production should be avoided as much as possible, to avoid data appearing in the console (always assume the worst, 0 trust policy).
My idea would be adding a new log or debug option, defaulting to false, that when set to true will log. Also since it's an error, I'd rather use console.error and maybe add a reference to the plugin in the log to help the user know it originates from the plugin?
You are right. It is not friendly to print the error message directly. It may be a good idea to add the debug option.
And console.error("[pinia-plugin-persistedstate]", error) maybe is a simple way to let the user know the origin of the error.
If you can add this to the PR, it'd be nice, if not i can do it when i have some time :)