pinia-plugin-persistedstate icon indicating copy to clipboard operation
pinia-plugin-persistedstate copied to clipboard

Add error message printing

Open wukong-c opened this issue 3 years ago • 3 comments

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

wukong-c avatar Sep 21 '22 10:09 wukong-c

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?

prazdevs avatar Sep 21 '22 16:09 prazdevs

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.

wukong-c avatar Sep 22 '22 08:09 wukong-c

If you can add this to the PR, it'd be nice, if not i can do it when i have some time :)

prazdevs avatar Sep 22 '22 09:09 prazdevs