dmaxwell commited on
Commit
787e14c
·
verified ·
1 Parent(s): eb96b8f

Include error handling

Browse files
Files changed (1) hide show
  1. index.js +5 -1
index.js CHANGED
@@ -16,7 +16,11 @@ imageUpload.addEventListener("change", async (e) => {
16
  const image = e.target.files[0];
17
 
18
  if (!image) {
19
- return;
 
 
 
 
20
  }
21
 
22
  imageContainer.innerHTML = "";
 
16
  const image = e.target.files[0];
17
 
18
  if (!image) {
19
+ return errorMsg.textContent = "The uploaded file is not an image. Please try again.";
20
+ }
21
+
22
+ if (image.type === "image/svg+xml") {
23
+ return errorMsg.textContent = "SVG images are not supported. Please try again.";
24
  }
25
 
26
  imageContainer.innerHTML = "";