wrap localstorage calls in try / catch block