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