Avoid NPE if adding a log line before the script header is set

This commit is contained in:
2024-06-19 16:48:05 -05:00
parent 3d7df30db4
commit 564a5e1095

View File

@ -94,7 +94,7 @@ public class BuildScriptLogAndScriptLogLineExecutionLogger implements QCodeExecu
protected QRecord buildDetailLogRecord(String logLine)
{
return (new QRecord()
.withValue("scriptLogId", scriptLog.getValue("id"))
.withValue("scriptLogId", scriptLog == null ? null : scriptLog.getValue("id"))
.withValue("timestamp", Instant.now())
.withValue("text", truncate(logLine)));
}
@ -145,6 +145,14 @@ public class BuildScriptLogAndScriptLogLineExecutionLogger implements QCodeExecu
{
this.executeCodeInput = executeCodeInput;
this.scriptLog = buildHeaderRecord(executeCodeInput);
if(scriptLogLines != null)
{
for(QRecord scriptLogLine : scriptLogLines)
{
scriptLogLine.setValue("scriptLogId", scriptLog.getValue("id"));
}
}
}
catch(Exception e)
{