Commit 9093b48a authored by sajolida's avatar sajolida
Browse files

Catch error when file is null or undefined

parent 4f79e5fe
......@@ -116,6 +116,9 @@ document.addEventListener("DOMContentLoaded", function() {
else if (result === "failed-again") {
show(document.getElementById("verification-failed-again"));
}
else if (result === "error-file") {
show(document.getElementById("verification-error-file"));
}
else if (result === "error-json") {
show(document.getElementById("verification-error-json"));
document.getElementById("checksum-file").setAttribute("href", URLofJsonFileContainingChecksums);
......@@ -131,6 +134,7 @@ document.addEventListener("DOMContentLoaded", function() {
hide(document.getElementById("verification-successful"));
hide(document.getElementById("verification-failed"));
hide(document.getElementById("verification-failed-again"));
hide(document.getElementById("verification-error-file"));
hide(document.getElementById("verification-error-json"));
hide(document.getElementById("verification-error-image"));
show(document.getElementById("verification"));
......@@ -147,8 +151,14 @@ document.addEventListener("DOMContentLoaded", function() {
/* Verification logic functions */
async function verifyFile(e, elm) {
file = elm.files[0]
try {
file = elm.files[0];
showVerifyingDownload(file.name);
} catch(err) {
showVerificationResult("error-file");
return;
}
try {
var response=await fetch(URLofJsonFileContainingChecksums);
......@@ -306,5 +316,6 @@ document.addEventListener("DOMContentLoaded", function() {
// showVerificationResult("failed-again");
// showVerificationResult("error-json");
// showVerificationResult("error-image");
// verifyFile(null, null);
});
......@@ -145,6 +145,12 @@ were solved, and known issues that have already been identified.</p>
</div>
<p>Please try to download again from a different place or a different computer&hellip;</p>
</div>
<div id="verification-error-file" class="block">
<p>[[!img lib/cross.png class="icon" link="no" alt=""]]<b>Error selecting image.</b></p>
<p class="usb upgrade download-only-img">Make sure that you select a USB image that is readable by your browser.</p>
<p class="dvd vm download-only-iso">Make sure that you select an ISO image that is readable by your browser.</p>
<p><a id="retry-json">Retry&hellip;</a></p>
</div>
<div id="verification-error-json" class="block">
<p>[[!img lib/cross.png class="icon" link="no" alt=""]]<b>Error downloading <a id="checksum-file" href="">checksum file</a> from our website.</b></p>
<p>Make sure that your browser is connected to the Internet.</p>
......
......@@ -18,6 +18,7 @@
#verification-successful,
#verification-failed,
#verification-failed-again,
#verification-error-file,
#verification-error-json,
#verification-error-image,
#skip-download,
......@@ -147,7 +148,7 @@ img.icon {
vertical-align: bottom;
}
#verification-error-json, #verification-error-image {
#verification-error-file, #verification-error-json, #verification-error-image {
margin-top: 1.5em;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment