Wrap localStorage calls in try/catch