Skip to content

Commit

Permalink
Trap errors writing to log file
Browse files Browse the repository at this point in the history
  • Loading branch information
mgobat committed Jun 16, 2023
1 parent c1fef3b commit 873ce5c
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,21 @@ function initConfiguration() {
//Function to write log messages
function WriteLog(message) {
let d = new Date();
fs.appendFileSync(logFile, d.toISOString() + ": " + message + "\n");
try {
fs.appendFileSync(logFile, d.toISOString() + ": " + message + "\n");
}
catch (e) {
let options = {
type: 'error',
buttons: ['OK'],
title: 'Could not write to log',

};
options.message = 'An error occurred trying to write to the log file.\r\n' + e.message;
if (!service) {
//alert ('An error occurred trying to write to the log file.\r\n' + e.message);
}
}
}

//Catch 'save-settings' from renderer
Expand Down

0 comments on commit 873ce5c

Please sign in to comment.