From 9d5e6b5334c12c436ddcc8ae89fe0729aac24528 Mon Sep 17 00:00:00 2001 From: Joe Knapper Date: Tue, 20 May 2025 16:11:04 +0100 Subject: [PATCH] Default error messages if the log is empty, or the log message is empty --- .../labThingsComponents/actionButton.vue | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/webapp/src/components/labThingsComponents/actionButton.vue b/webapp/src/components/labThingsComponents/actionButton.vue index 7b49e347..fdcff837 100644 --- a/webapp/src/components/labThingsComponents/actionButton.vue +++ b/webapp/src/components/labThingsComponents/actionButton.vue @@ -297,9 +297,17 @@ export default { else if (result == "error") { // Pass the error string back with reject if (!this.progress) this.progress = 1; - // Assume that the most recent message in the log is the error message - // and raise an Error with that message - reject(new Error(response.data.log.at(-1).message)); + // Test whether the log is empty. If so, return a default message + if (response.data.log.length == 0) { + var message = "Unexpected error, please check the logs"; + } + // Otherwise assume that the most recent message in the log is the error message + // If it's the empty string, use a default message + else { + message = response.data.log.at(-1).message||"Unexpected error, please check the logs"; + } + // Raise an Error with the chosen message + reject(new Error(message)); } // If task ends without reporting an error // (NB this includes cancellation)