Default error messages if the log is empty, or the log message is empty

This commit is contained in:
Joe Knapper 2025-05-20 16:11:04 +01:00
parent 852a003fae
commit 9d5e6b5334

View file

@ -297,9 +297,17 @@ 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;
// Assume that the most recent message in the log is the error message // Test whether the log is empty. If so, return a default message
// and raise an Error with that message if (response.data.log.length == 0) {
reject(new Error(response.data.log.at(-1).message)); 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 // If task ends without reporting an error
// (NB this includes cancellation) // (NB this includes cancellation)