Skip to content

Commit

Permalink
feat: Show server error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
joostvanderborg committed May 16, 2024
1 parent 53e08ca commit 6527ee1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/app/static-resources/static/js/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,21 @@ function post(url, params, sendingButton) {
if(data.redirect_to) {
window.location.replace(data.redirect_to);
}
if(data.error) {
showErrorMessage(sendingButton, data.error);
}
})
.catch(error => {
console.error(error);
resetButton(sendingButton);
const errorElement = htmlStringToElement('<p class="warning">Er is iets misgegaan. Probeer het opnieuw.</p>');
sendingButton.parentElement.appendChild(errorElement);
showErrorMessage(sendingButton, 'Er is iets misgegaan.');
});
}

addFormEventHandlers();
addCopyToClipboardButtons();

function showErrorMessage(besidesElement, error) {
const errorElement = htmlStringToElement(`<p class="warning">${error}</p>`);
besidesElement.parentElement.appendChild(errorElement);
}

0 comments on commit 6527ee1

Please sign in to comment.