Skip to content

Commit f9942fd

Browse files
committed
add error logging in frontend
1 parent ec13dc9 commit f9942fd

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.env
2+
node_modules
3+
pnpm-lock.yaml
4+
package-lock.json

public/script.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,15 +227,20 @@ document.addEventListener("DOMContentLoaded", function () {
227227
showNotification(`${file.name} uploaded successfully!`, "success");
228228
} else {
229229
progressText.innerText = "Failed";
230-
showNotification(`Failed to upload ${file.name}`, "error");
230+
showNotification(`${response.error || "Unknown server error"}`, "error");
231231
}
232232
} catch (error) {
233233
progressText.innerText = "Error";
234234
showNotification("Failed to process server response", "error");
235235
}
236236
} else {
237237
progressText.innerText = "Error";
238-
showNotification(`Server error (${xhr.status})`, "error");
238+
try {
239+
const response = JSON.parse(xhr.responseText);
240+
showNotification(`${response.error || "Unknown server error"}`, "error");
241+
} catch (e) {
242+
showNotification(`Server error (${xhr.status})`, "error");
243+
}
239244
}
240245
};
241246

0 commit comments

Comments
 (0)