square / svelte-store

528 stars 35 forks source link

Add autocatch+and+log feature #29

Closed Akolyte01 closed 2 years ago

Akolyte01 commented 2 years ago

Existing functionality works well for happy-path but unhappy-path could use some work.

As is, if an async store fails to load it will return the promise rejection with its load function. This can be caught in templates by using safeLoad but if this is done then the error is not exposed in the console or caught by automatic error logging.

This can be worked around by adding a try catch block to every async store and manually logging any errors before re-throwing. Instead of doing this every time this should be an option in this package.

Allow for the passing in of an error logger callback in a configuration step that will be called whenever there is an error in the load function of an async store.

coldino commented 2 years ago

I came here looking for such a feature. Currently trying to flesh out my "unhappy"-path solutions and it seems to do it you have to throw away all the nice usage patterns. Even to debug these things right now is problematic.

Akolyte01 commented 2 years ago

As a heads up this feature is in beta testing at the moment and should be released soon!

Akolyte01 commented 2 years ago

Okay took longer than expected but 1.0.10 is now out! This is use case is addressed with the logAsyncErrors feature