Skip to content

Commit

Permalink
if saving fails, alert()
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuki Adachi committed Jun 17, 2022
1 parent 3a9b2a4 commit 6a8e68f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions options.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ const saveObjectInLocalStorage = async function(obj) {

document.getElementById("saveConfigs").addEventListener("click",async function(e){
if(document.getElementById("textareaConfigs").value){
let jsonConfigs = JSON.parse(document.getElementById("textareaConfigs").value);
await saveObjectInLocalStorage({'configs': jsonConfigs});
alert('Configs are saved.');
try{
let jsonConfigs = JSON.parse(document.getElementById("textareaConfigs").value);
await saveObjectInLocalStorage({'configs': jsonConfigs});
alert('Configs are saved.');
}catch(error){
alert(error.message);
}
}
},false);

Expand Down Expand Up @@ -93,7 +97,7 @@ function getDefaultConfigs(){
"toast": {
"position": "center",
"icon": "error",
"title": "Hey, Watch out! It's PRODUCTION!!!",
"title": "It's PRODUCTION!!!",
"showConfirmButton": false,
"timer": 1000
},
Expand Down

0 comments on commit 6a8e68f

Please sign in to comment.