How do you know if a save or load operation has failed?

Easy Save 2 has been replaced by Easy Save 3, so is no longer supported.
Locked
arcifus
Posts: 4
Joined: Wed Jan 10, 2018 4:31 am

How do you know if a save or load operation has failed?

Post by arcifus »

How do we programmatically check during runtime whether a data save or load operation has failed? There are no success or failure results in your API. There are no exceptions being thrown either by the API (unless something crashes internally).
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: How do you know if a save or load operation has failed?

Post by Joel »

Hi there,

Exceptions are thrown when something goes wrong, so you can use it in a try/catch block (for example, a FileNotFoundException will be thrown when data is missing).

If exceptions are not being thrown for you, make sure you have exceptions enabled in your Unity project settings.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
arcifus
Posts: 4
Joined: Wed Jan 10, 2018 4:31 am

Re: How do you know if a save or load operation has failed?

Post by arcifus »

My bad, exceptions ARE being thrown. Thanks.
arcifus
Posts: 4
Joined: Wed Jan 10, 2018 4:31 am

Re: How do you know if a save or load operation has failed?

Post by arcifus »

Sorry about the back n forth on this. Further testing reveals there are a couple of places that are missing exceptions or error handling:

1) When you read a tag (using ES2Reader) into an incompatible type, we are only given an error in the console. This is limiting when you want to programmatically check for this situation.

2) When you read a non-existent tag (using ES2Reader) we are given an error in the console. Sure we can check for Exists prior to that, but there are situations where a try catch would be more elegant.

Generally it seems that exceptions are not being generated uniformly across the API or am I missing something here?

Thanks.
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: How do you know if a save or load operation has failed?

Post by Joel »

Hi there,

There are certain areas where we intentionally don't throw exceptions (especially where ES2Reader/Writer is concerned) because it's an error which should not occur at runtime.

If you wish, you can modify the code to replace the Debug.Log with an exception yourself.

Note that Easy Save 3 (which is currently in beta) throws exceptions for almost everything as we've structured it differently, so certain errors are now recoverable.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Locked