Skip to content
Snippets Groups Projects
Commit d6c30951 authored by Niko Ehrenfeuchter's avatar Niko Ehrenfeuchter :keyboard:
Browse files

Sending emails on errors is now handled by the logger.

Therefore the corresponding code can be simplified a lot.

Refers to #3
parent ecf825ac
No related branches found
No related tags found
No related merge requests found
......@@ -350,10 +350,8 @@ namespace AutoTx
_mainTimer.Enabled = true;
}
catch (Exception ex) {
// FIXME: combine log and admin-email!
var msg = string.Format("Error in OnStart(): {0}", ex.Message);
Log.Error(msg);
SendAdminEmail(msg);
Log.Error("Error in OnStart(): {0}", ex.Message);
throw;
}
// read the build timestamp from the resources:
......@@ -384,10 +382,7 @@ namespace AutoTx
_roboCommand.Stop();
}
catch (Exception ex) {
// FIXME: combine log and admin-email!
var msg = string.Format("Error terminating the RoboCopy process: {0}", ex.Message);
Log.Error(msg);
SendAdminEmail(msg);
Log.Error("Error terminating the RoboCopy process: {0}", ex.Message);
}
_status.TransferInProgress = true;
Log.Info("Not all files were transferred - will resume upon next start");
......@@ -717,7 +712,6 @@ namespace AutoTx
/// </summary>
private void MoveToManagedLocation(DirectoryInfo userDir) {
string errMsg;
string logMsg; // TODO / FIXME: cleanup var after fixing mail-logging
try {
// first check for individual files and collect them:
CollectOrphanedFiles(userDir);
......@@ -728,10 +722,7 @@ namespace AutoTx
// if the user has no directory on the destination move to UNMATCHED instead:
if (string.IsNullOrWhiteSpace(DestinationPath(userDir.Name))) {
// TODO / FIXME: combine log and admin-email!
logMsg = string.Format("Found unmatched incoming dir: {0}", userDir.Name);
Log.Error(logMsg);
SendAdminEmail(logMsg);
Log.Error("Found unmatched incoming dir: {0}", userDir.Name);
target = "UNMATCHED";
}
......@@ -749,10 +740,7 @@ namespace AutoTx
catch (Exception ex) {
errMsg = ex.Message;
}
// TODO / FIXME: combine log and admin-email!
logMsg = string.Format("MoveToManagedLocation({0}) failed: {1}", userDir.FullName, errMsg);
Log.Error(logMsg);
SendAdminEmail(logMsg);
Log.Error("MoveToManagedLocation({0}) failed: {1}", userDir.FullName, errMsg);
}
/// <summary>
......@@ -787,10 +775,7 @@ namespace AutoTx
catch (Exception ex) {
errMsg = ex.Message;
}
// TODO / FIXME: combine log and admin-email!
var msg = string.Format("MoveToGraceLocation() failed: {0}", errMsg);
Log.Error(msg);
SendAdminEmail(msg);
Log.Error("MoveToGraceLocation() failed: {0}", errMsg);
}
/// <summary>
......@@ -836,11 +821,8 @@ namespace AutoTx
}
}
catch (Exception ex) {
// TODO / FIXME: combine log and admin-email!
var msg = string.Format("Error moving directories: [{0}] > [{1}]\n{2}",
Log.Error("Error moving directories: [{0}] > [{1}]\n{2}",
sourceDir.FullName, destPath, ex.Message);
Log.Error(msg);
SendAdminEmail(msg);
return false;
}
return true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment