Skip to contentSkip to conversation

report-error: Handle the case no logfile exists

PATCH New Richard Purdie 1 participant 1 message Dec 20, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 report-error: Handle the case no logfile exists

If the task fails early, no error log may exist. Currently we crash in that case, this handles the situation more gracefully.

meta/classes/report-error.bbclass +6 -3
index 5fe2355..8b30422 100644
@@ -44,11 +44,14 @@ python errorreport_handler () {
             task = e.task
             taskdata={}
             log = e.data.getVar('BB_LOGFILE', True)
-            logFile = open(log, 'r')
             taskdata['package'] = e.data.expand("${PF}")
             taskdata['task'] = task
-            taskdata['log'] = logFile.read()
-            logFile.close()
+            if log:
+                logFile = open(log, 'r')
+                taskdata['log'] = logFile.read()
+                logFile.close()
+            else:
+                taskdata['log'] = "No Log"
             jsondata = json.loads(errorreport_getdata(e))
             jsondata['failures'].append(taskdata)
             errorreport_savedata(e, jsondata, "error-report.txt")