🎨 Display error message if it happens

This commit is contained in:
Clement Desmidt 2018-10-18 23:06:56 +02:00
parent 874be054fe
commit 394f4af8c8
2 changed files with 6 additions and 6 deletions

View File

@ -30,12 +30,12 @@ ext.runtime.onMessage.addListener(
body: new URLSearchParams(queryString)
})
.then(function(response) {
sendResponse({ action: "saved" });
if (200 === response.status) {
sendResponse({action: "saved"});
} else {
sendResponse({action: "error", status: response.status, error: response.statusText});
}
});
// var destination = url+"?v=1&u="+encodeURIComponent(data.url)+"&t="+encodeURIComponent(data.title)+"&m="+encodeURIComponent(token);
// fetch(destination).then(function(response) {
// sendResponse({ action: "saved" });
// });
});
return true; // https://stackoverflow.com/a/20077854

View File

@ -62,7 +62,7 @@ popup.addEventListener("click", function(e) {
if (response && response.action === "saved") {
renderMessage(ext.i18n.getMessage("savedSuccessfully"));
} else {
renderMessage(ext.i18n.getMessage("unknownError"));
renderMessage(response.error + " ("+response.status+")");
}
});
}