Skip to content

Commit

Permalink
Merge pull request #56 from clearlydefined/roman/logging_fixes
Browse files Browse the repository at this point in the history
Improve error handling and logging in blobstorage-backupdata
  • Loading branch information
RomanIakovlev authored Jun 12, 2024
2 parents f8cff80 + deb6314 commit 0b22df2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions tools/blobstorage-backupdata/BackupJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ private async Task SaveData(
{
var retryPolicy = Policy
.Handle<MongoConnectionException>()
.Or<MongoExecutionTimeoutException>()
.Or<TimeoutException>()
.Or<AggregateException>()
.WaitAndRetryAsync(new[]
{
TimeSpan.FromSeconds(1),
Expand Down
16 changes: 15 additions & 1 deletion tools/blobstorage-backupdata/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,21 @@ internal static void Main()
ILogger logger = loggerFactory.CreateLogger(nameof(Program));
logger.LogInformation("Backup job started.");
var backupJob = CreateBackupJob(loggerFactory);
backupJob.ProcessJob().Wait();
try
{
backupJob.ProcessJob().Wait();
}
catch (AggregateException ae)
{
foreach (var e in ae.InnerExceptions)
{
logger.LogError(e, "Backup job failed.");
}
}
catch (Exception e)
{
logger.LogError(e, "Backup job failed.");
}
logger.LogInformation("Backup job completed.");
}

Expand Down

0 comments on commit 0b22df2

Please sign in to comment.