Skip to content
This repository has been archived by the owner on Mar 1, 2022. It is now read-only.

Commit

Permalink
Removed try/catch block in LogglySink
Browse files Browse the repository at this point in the history
Removed the try/catch block in the EmitBatchAsync method of LogglySink to allow Serilog to handle exceptions centrally, based on PR feedback.
  • Loading branch information
danjagnow committed Aug 18, 2020
1 parent 7073741 commit f37a36c
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions src/Serilog.Sinks.Loggly/Sinks/Loggly/LogglySink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +81,16 @@ public LogglySink(IFormatProvider formatProvider, int batchSizeLimit, TimeSpan p
/// not both.</remarks>
protected override async Task EmitBatchAsync(IEnumerable<LogEvent> events)
{
try
{
LogResponse response = await _client.Log(events.Select(_converter.CreateLogglyEvent)).ConfigureAwait(false);
LogResponse response = await _client.Log(events.Select(_converter.CreateLogglyEvent)).ConfigureAwait(false);

switch (response.Code)
{
case ResponseCode.Error:
SelfLog.WriteLine("LogglySink received an Error response: {0}", response.Message);
break;
case ResponseCode.Unknown:
SelfLog.WriteLine("LogglySink received an Unknown response: {0}", response.Message);
break;
}
}
catch (Exception ex)
switch (response.Code)
{
SelfLog.WriteLine("LogglySink encountered an exception: {0}", ex);
case ResponseCode.Error:
SelfLog.WriteLine("LogglySink received an Error response: {0}", response.Message);
break;
case ResponseCode.Unknown:
SelfLog.WriteLine("LogglySink received an Unknown response: {0}", response.Message);
break;
}
}

Expand Down

0 comments on commit f37a36c

Please sign in to comment.