Some browsers (like Safari in private mode) will expose the localStorage API but throw when it is accessed.