QuotaExceededError (DOM Exception 22): The quota has been exceeded on Safari in incognito
You can't use local storage in incognito mode. By wrapping your setItem or getItem calls in a try/catch just helps your code handle the failed usage of local storage, and then alert the user that they need to use your application in a non-private mode.
The error you're getting is by design.