Update static/script.js
Browse files- static/script.js +7 -2
static/script.js
CHANGED
|
@@ -77,7 +77,12 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
| 77 |
method: 'POST',
|
| 78 |
body: formData
|
| 79 |
})
|
| 80 |
-
.then(response =>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
.then(blob => {
|
| 82 |
const url = URL.createObjectURL(blob);
|
| 83 |
result.style.display = 'block';
|
|
@@ -87,7 +92,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
| 87 |
})
|
| 88 |
.catch(error => {
|
| 89 |
console.error('Error:', error);
|
| 90 |
-
alert('An error occurred while processing the file
|
| 91 |
});
|
| 92 |
});
|
| 93 |
});
|
|
|
|
| 77 |
method: 'POST',
|
| 78 |
body: formData
|
| 79 |
})
|
| 80 |
+
.then(response => {
|
| 81 |
+
if (!response.ok) {
|
| 82 |
+
return response.json().then(err => { throw new Error(err.error) });
|
| 83 |
+
}
|
| 84 |
+
return response.blob();
|
| 85 |
+
})
|
| 86 |
.then(blob => {
|
| 87 |
const url = URL.createObjectURL(blob);
|
| 88 |
result.style.display = 'block';
|
|
|
|
| 92 |
})
|
| 93 |
.catch(error => {
|
| 94 |
console.error('Error:', error);
|
| 95 |
+
alert('An error occurred while processing the file: ' + error.message);
|
| 96 |
});
|
| 97 |
});
|
| 98 |
});
|