Updated comment, test most recent log is ERROR

This commit is contained in:
Joe Knapper 2025-05-20 16:20:35 +01:00
parent 9d5e6b5334
commit 67c5c74753

View file

@ -297,12 +297,14 @@ export default {
else if (result == "error") { else if (result == "error") {
// Pass the error string back with reject // Pass the error string back with reject
if (!this.progress) this.progress = 1; if (!this.progress) this.progress = 1;
// Test whether the log is empty. If so, return a default message // Test whether the log is empty or the most recent message is not from an error
if (response.data.log.length == 0) { // If so, return a default message
if (response.data.log.length == 0 | response.data.log.at(-1).levelname != "ERROR") {
var message = "Unexpected error, please check the logs"; var message = "Unexpected error, please check the logs";
} }
// Otherwise assume that the most recent message in the log is the error message // As LabThings Actions add the message from any raised exception to the log, the
// If it's the empty string, use a default message // last message in the log is the message from the Exception.
//If the Exception was raised with no message, use a default.
else { else {
message = response.data.log.at(-1).message||"Unexpected error, please check the logs"; message = response.data.log.at(-1).message||"Unexpected error, please check the logs";
} }