3 ms·
Would you mind taking a look at http://github.com/nfriedly/Javascript-Flash-Cookies/blob/master/src/Storage.as http://github.com/nfriedly/Javascript-Flash-Cooki
by nfriedly 16y ago
Would you mind taking a look at http://github.com/nfriedly/Javascript-Flash-Cookies/blob/master/src/Storage.as http://github.com/nfriedly/Javascript-Flash-Cookies/blob/mas... and letting me know if anything could be improved. For one thing, I think I have more try/catch statements than I need, but I'm not really sure what can throw errors.
(This is a flash cookies library. My company doesn't use it to invade people's privacy, but I know it could be used for that. If you don't want to contribute to something like that, I'd understand.)
Either way, thanks for the offer!
- dgant 16y agoI haven't worked with Flash cookies so I have no feedback about that domain specifically. There are plenty of legitimate uses for them, so there's no need to add a disclaimer! The Flex references do a pretty good job of documenting what errors are thrown by various library methods. I recommend doing error handling at the first point where an error can be thrown, because AS3's unchecked error system makes it difficult to otherwise ensure that errors don't unintentionally propagate all the way up the stack. Often, all you will care about is success/failure of a call. That appears to be true in your code. In that case, you might as well Don't Repeat Yourself: just catch(error:Error), and proceed. If you want to record which particular error occurred, you can log error.message or flash.utils.getQualifiedClassName(error). Tangentially, that also futureproofs you against changes to the API like additional Error types that may be thrown.