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 src="js/functions.js"></script>
<script> <script>
try {
closedTopics = JSON.parse(localStorage.getItem("closedTopics")) closedTopics = JSON.parse(localStorage.getItem("closedTopics"))
} catch (e) {
closedTopics = []
}
if(!closedTopics) { if(!closedTopics) {
closedTopics = [] closedTopics = []
} }
try{
actualTopic = JSON.parse(localStorage.getItem("actualTopic")) actualTopic = JSON.parse(localStorage.getItem("actualTopic"))
} catch (e) {
initializeNewTopic()
}
if(!actualTopic) { if(!actualTopic) {
initializeNewTopic() initializeNewTopic()
} }