Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
943 changes: 943 additions & 0 deletions .history/src/CsvHelper/CsvWriter_20251215023120.cs

Large diffs are not rendered by default.

940 changes: 940 additions & 0 deletions .history/src/CsvHelper/CsvWriter_20251215024544.cs

Large diffs are not rendered by default.

940 changes: 940 additions & 0 deletions .history/src/CsvHelper/CsvWriter_20251215024545.cs

Large diffs are not rendered by default.

944 changes: 944 additions & 0 deletions .history/src/CsvHelper/CsvWriter_20251215024941.cs

Large diffs are not rendered by default.

949 changes: 949 additions & 0 deletions .history/src/CsvHelper/CsvWriter_20251215025049.cs

Large diffs are not rendered by default.

954 changes: 954 additions & 0 deletions .history/src/CsvHelper/CsvWriter_20251215025215.cs

Large diffs are not rendered by default.

959 changes: 959 additions & 0 deletions .history/src/CsvHelper/CsvWriter_20251215025348.cs

Large diffs are not rendered by default.

959 changes: 959 additions & 0 deletions .history/src/CsvHelper/CsvWriter_20251215025441.cs

Large diffs are not rendered by default.

963 changes: 963 additions & 0 deletions .history/src/CsvHelper/CsvWriter_20251215025604.cs

Large diffs are not rendered by default.

963 changes: 963 additions & 0 deletions .history/src/CsvHelper/CsvWriter_20251215025721.cs

Large diffs are not rendered by default.

96 changes: 58 additions & 38 deletions src/CsvHelper/CsvWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,15 @@ public virtual void WriteRecord<T>(T? record)
}
}
catch (Exception ex) when (ex is not CsvHelperException)
{
throw new WriterException(context, "An unexpected error occurred. See inner exception for details.", ex);
}
}
{
throw new WriterException(
context,
"An unexpected error occurred while writing records. " +
"This may be caused by a missing dependency. See inner exception for details.",
ex
);
}


/// <inheritdoc/>
public virtual void WriteRecords(IEnumerable records)
Expand Down Expand Up @@ -391,17 +396,14 @@ public virtual void WriteRecords(IEnumerable records)
while (enumerator.MoveNext());
}
catch (Exception ex) when (ex is not CsvHelperException)
{
throw new WriterException(context, "An unexpected error occurred. See inner exception for details.", ex);
}
finally
{
if (enumerator is IDisposable en)
{
en.Dispose();
}
}
}
{
throw new WriterException(
context,
"An unexpected error occurred while writing records. " +
"This may be caused by a missing dependency. See inner exception for details.",
ex
);
}

/// <inheritdoc/>
public virtual void WriteRecords<T>(IEnumerable<T> records)
Expand Down Expand Up @@ -444,19 +446,23 @@ public virtual void WriteRecords<T>(IEnumerable<T> records)
NextRecord();
}
while (enumerator.MoveNext());
}
catch (Exception ex) when (ex is not CsvHelperException)
{
throw new WriterException(context, "An unexpected error occurred. See inner exception for details.", ex);
}
finally
{
if (enumerator is IDisposable en)
{
en.Dispose();
}
}
}
}
catch (Exception ex) when (ex is not CsvHelperException)
{
throw new WriterException(
context,
"An unexpected error occurred while writing records. " +
"This may be caused by a missing dependency. See inner exception for details.",
ex
);
}
finally
{
if (enumerator is IDisposable en)
{
en.Dispose();
}
}

/// <inheritdoc/>
public virtual async Task WriteRecordsAsync(IEnumerable records, CancellationToken cancellationToken = default)
Expand Down Expand Up @@ -502,7 +508,11 @@ public virtual async Task WriteRecordsAsync(IEnumerable records, CancellationTok
}
catch (Exception ex) when (ex is not CsvHelperException)
{
throw new WriterException(context, "An unexpected error occurred. See inner exception for details.", ex);
throw new WriterException(
"An unexpected error occurred while writing records. " +
"This may be caused by a missing dependency. See inner exception for details.",
ex
);
}
finally
{
Expand Down Expand Up @@ -562,7 +572,12 @@ public virtual async Task WriteRecordsAsync<T>(IEnumerable<T> records, Cancellat
}
catch (Exception ex) when (ex is not CsvHelperException)
{
throw new WriterException(context, "An unexpected error occurred. See inner exception for details.", ex);
throw new WriterException(
context,
"An unexpected error occurred while writing records. " +
"This may be caused by a missing dependency. See inner exception for details.",
ex
);
}
finally
{
Expand Down Expand Up @@ -621,14 +636,19 @@ public virtual async Task WriteRecordsAsync<T>(IAsyncEnumerable<T> records, Canc
while (await enumerator.MoveNextAsync().ConfigureAwait(false));
}
catch (Exception ex) when (ex is not CsvHelperException)
{
throw new WriterException(context, "An unexpected error occurred. See inner exception for details.", ex);
}
finally
{
await enumerator.DisposeAsync().ConfigureAwait(false);
}
}
{
throw new WriterException(
context,
"An unexpected error occurred while writing records. " +
"This may be caused by a missing dependency. See inner exception for details.",
ex
);
}
finally
{
await enumerator.DisposeAsync().ConfigureAwait(false);
}


/// <inheritdoc/>
public virtual void NextRecord()
Expand Down