error handling with local Storage

This commit is contained in:
schrom01 2023-02-15 00:17:44 +01:00
parent a9cad34e71
commit fbbd126cd6
1 changed files with 10 additions and 2 deletions

View File

@ -119,12 +119,20 @@
<script src="js/functions.js"></script>
<script>
closedTopics = JSON.parse(localStorage.getItem("closedTopics"))
try {
closedTopics = JSON.parse(localStorage.getItem("closedTopics"))
} catch (e) {
closedTopics = []
}
if(!closedTopics) {
closedTopics = []
}
actualTopic = JSON.parse(localStorage.getItem("actualTopic"))
try{
actualTopic = JSON.parse(localStorage.getItem("actualTopic"))
} catch (e) {
initializeNewTopic()
}
if(!actualTopic) {
initializeNewTopic()
}