fix: add error handling for logfile writes in Analytics

This commit is contained in:
Paul Gauthier (aider) 2024-12-04 13:51:06 -08:00
parent c51afc952c
commit 699e283890

View file

@ -219,7 +219,9 @@ class Analytics:
"user_id": self.user_id,
"time": int(time.time()),
}
# ai try/except OsErrors, ignore them AI!
with open(self.logfile, "a") as f:
json.dump(log_entry, f)
f.write("\n")
try:
with open(self.logfile, "a") as f:
json.dump(log_entry, f)
f.write("\n")
except OSError:
pass # Ignore OS errors when writing to logfile