Skip to content

Commit

Permalink
Add direction information to exception logging
Browse files Browse the repository at this point in the history
References #1
  • Loading branch information
andreashuber-lawo committed Oct 29, 2015
1 parent 7b9eab8 commit 15f8f1f
Showing 1 changed file with 27 additions and 15 deletions.
42 changes: 27 additions & 15 deletions Lawo.GlowAnalyzerProxy.Main/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -355,29 +355,36 @@ private async Task ForwardLoop(TcpListener listener)

try
{
using (this.ConsumerConnection.Client = await listener.AcceptTcpClientAsync())
{
listener.Stop();
this.ConsumerConnection.Client = await listener.AcceptTcpClientAsync();
listener.Stop();
}
catch (Exception ex)
{
await EnqueueLogOperationAsync(
logInfo, "Exception", null, null, i => i.Logger.LogException("Consumer to Proxy", ex));
}

using (this.ConsumerConnection.Client)
{
try
{
using (this.ProviderConnection.Client = await ConnectToProvider())
{
await Task.WhenAll(
this.ForwardFromConsumerAsync(logInfo), this.ForwardFromProviderAsync(logInfo));
}
}
catch (Exception ex)
{
await EnqueueLogOperationAsync(
logInfo, "Exception", null, null, i => i.Logger.LogException("Proxy to Provider", ex));
}
}
catch (Exception ex)
{
await EnqueueLogOperationAsync(
logInfo, "Exception", null, null, i => i.Logger.LogException(null, ex));
}
finally
{
this.ConsumerConnection.Client = null;
this.ProviderConnection.Client = null;
await EnqueueLogOperationAsync(logInfo, null, null, null, i => { i.Dispose(); return new EventInfo(); });
listener.Start();
}

this.ConsumerConnection.Client = null;
this.ProviderConnection.Client = null;
await EnqueueLogOperationAsync(logInfo, null, null, null, i => { i.Dispose(); return new EventInfo(); });
listener.Start();
}
else
{
Expand Down Expand Up @@ -450,6 +457,11 @@ await this.EnqueueLogOperationAsync(
catch (ObjectDisposedException)
{
}
catch (Exception ex)
{
await EnqueueLogOperationAsync(
logInfo, "Exception", shortDirection, null, i => i.Logger.LogException(direction, ex));
}
finally
{
payloadStream.Dispose();
Expand Down

0 comments on commit 15f8f1f

Please sign in to comment.