Skip to content
Snippets Groups Projects
Commit 3bdb00f4 authored by Lukas Schneider's avatar Lukas Schneider
Browse files

Improve error handling

parent b03b4ae5
No related branches found
No related tags found
No related merge requests found
......@@ -126,14 +126,22 @@
updateRecentlyBoughtList();
function buy(id) {
error = error => showError(error.responseJSON, "Fehler beim Einkaufen");
error = error => {
err = null;
if (error && "responseJSON" in error) {
err = error.responseJSON
}
showError(err, "Fehler beim Einkaufen");
}
// Check if id is a valid integer
id = parseInt(id);
if (isNaN(id)) {
error();
error(null);
return;
}
// Send request to the server using a new token
tokenCall(token => {
$.ajax({
url: "{% url "buy_product" %}",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment