From 23b71a09c628af6b8b3a2f33b56c87d612766463 Mon Sep 17 00:00:00 2001 From: Leonid Nikitin Date: Thu, 23 Nov 2023 01:10:04 +0600 Subject: [PATCH] Added fallback for empty error messages. In the case where the data.errors object does not have any explicit errors, the diff adds a fallback. The resulting error message displayed will then be the general data message. This prevents situations where the user receives an empty error message. --- exmplate/script.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/exmplate/script.js b/exmplate/script.js index 67c7f88..d18e4e8 100644 --- a/exmplate/script.js +++ b/exmplate/script.js @@ -159,6 +159,9 @@ for (let key in data.errors) { errorMessage += data.errors[key] + '
'; } + if (errorMessage === '') { + errorMessage = data.message; + } setError(errorMessage, button); return }