diff --git a/src/CsvProc9000.Model/Result.cs b/src/CsvProc9000.Model/Result.cs index 17cd074..3796d32 100644 --- a/src/CsvProc9000.Model/Result.cs +++ b/src/CsvProc9000.Model/Result.cs @@ -7,14 +7,18 @@ public class Result { public Result( bool isSuccess, - T value = default) + T value = default, + string failureMessage = default) { IsSuccess = isSuccess; Value = value; + FailureMessage = failureMessage ?? string.Empty; } public bool IsSuccess { get; } public T Value { get; } + + public string FailureMessage { get; } } } diff --git a/src/CsvProc9000/Csv/CsvImporter.cs b/src/CsvProc9000/Csv/CsvImporter.cs index e8e1389..ebaa312 100644 --- a/src/CsvProc9000/Csv/CsvImporter.cs +++ b/src/CsvProc9000/Csv/CsvImporter.cs @@ -34,9 +34,9 @@ public async Task> ImportAsync( var file = await DoImportAsync(fileName, delimiter); return new Result(true, file); } - catch (IOException) + catch (IOException ex) { - return new Result(false); + return new Result(false, failureMessage: ex.Message); } } diff --git a/src/CsvProc9000/Jobs/CsvProcessJobWorker.cs b/src/CsvProc9000/Jobs/CsvProcessJobWorker.cs index fecddd8..23fde30 100644 --- a/src/CsvProc9000/Jobs/CsvProcessJobWorker.cs +++ b/src/CsvProc9000/Jobs/CsvProcessJobWorker.cs @@ -95,6 +95,9 @@ private async Task ImportFileAsync(CsvProcessJob job, Guid jobThreadId) if (result.IsSuccess) csvFile = result.Value; + else + _logger.LogWarning("T-{ThreadId} J-{JobId}# Import failed, because of '{Message}'. Retrying...", + jobThreadId, job.Id, result.FailureMessage); } return csvFile;