Wrap calls to localStorage in a try catch to prevent non-essential tasks from throwing errors