Wrap localStorage reference in a try/catch