Fix API error reporting

This commit is contained in:
GriffinR 2024-01-03 10:42:49 -05:00
parent 16f0a1a030
commit d1c25a8eca

View file

@ -112,16 +112,17 @@ bool Scripting::tryErrorJS(QJSValue js) {
if (!js.isError()) if (!js.isError())
return false; return false;
// The script engine is interrupted during project reopen, during which
// all script modules intentionally return as error objects.
// We don't need to report these "errors" to the user.
if (!instance || !instance->engine || !instance->engine->isInterrupted())
return false;
// Get properties of the error // Get properties of the error
QFileInfo file(js.property("fileName").toString()); QFileInfo file(js.property("fileName").toString());
QString fileName = file.fileName(); QString fileName = file.fileName();
QString lineNumber = js.property("lineNumber").toString(); QString lineNumber = js.property("lineNumber").toString();
QString errStr = js.toString();
// The script engine is interrupted during project reopen, during which
// all script modules intentionally return as error objects.
// We don't need to report these "errors" to the user.
//if (errStr == "Error: Interrupted")
// return false;
// Convert properties to message strings // Convert properties to message strings
QString fileErrStr = fileName == "undefined" ? "" : QString(" '%1'").arg(fileName); QString fileErrStr = fileName == "undefined" ? "" : QString(" '%1'").arg(fileName);
@ -130,7 +131,7 @@ bool Scripting::tryErrorJS(QJSValue js) {
logError(QString("Error in custom script%1%2: '%3'") logError(QString("Error in custom script%1%2: '%3'")
.arg(fileErrStr) .arg(fileErrStr)
.arg(lineErrStr) .arg(lineErrStr)
.arg(js.toString())); .arg(errStr));
return true; return true;
} }