Tuesday, March 17, 2009

Try/Catch with Shared Objects

I've done a bazillion Try/Catches in Java, so in a way this is not a big deal... but I'm a Flex tyro, so in another way this is a big deal.

We store a lot of data locally, as Shared Objects. This reduces the burden on the server and SQL Server. For the first time, though, some data schema changed, which means locally cached data now fails to load, and therefore throws an error. This was easily fixed, with try/catch.


// let's not assume the data is in good condition...
// if it's corrupted or the schema's been changed
// then we throw an error.
try {
cache[cacheName]
= SharedObject.getLocal(cacheName);
}
catch( err:Error ) {
... flag this data to be re-fetched ...
}


Problem solved.

No comments:

Post a Comment