Skip to content

Commit

Permalink
Now passing exceptions into FleckLog calls
Browse files Browse the repository at this point in the history
  • Loading branch information
statianzo committed Mar 4, 2011
1 parent 276b74e commit f47e9ba
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 12 deletions.
1 change: 0 additions & 1 deletion src/Fleck.Tests/Fleck.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
8 changes: 4 additions & 4 deletions src/Fleck/FleckLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ public class FleckLog

public static void Warn(string message, Exception ex = null)
{
LogAction(LogLevel.Warn, message,ex);
LogAction(LogLevel.Warn, message, ex);
}

public static void Error(string message, Exception ex = null)
{
LogAction(LogLevel.Error, message,ex);
LogAction(LogLevel.Error, message, ex);
}

public static void Debug(string message, Exception ex = null)
{
LogAction(LogLevel.Debug, message,ex);
LogAction(LogLevel.Debug, message, ex);
}

public static void Info(string message, Exception ex = null)
{
LogAction(LogLevel.Info, message,ex);
LogAction(LogLevel.Info, message, ex);
}

}
Expand Down
4 changes: 2 additions & 2 deletions src/Fleck/HandshakeHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void Shake(Socket socket)

Task<int>.Factory.FromAsync(socket.BeginReceive, socket.EndReceive, new[] {segment}, SocketFlags.None, null)
.ContinueWith(t => DoShake(state, t.Result))
.ContinueWith(t => FleckLog.Error("Exception thrown from method Receive:\n" + t.Exception.Message),
.ContinueWith(t => FleckLog.Error("Failed to recieve handshake", t.Exception),
TaskContinuationOptions.OnlyOnFaulted);
}

Expand Down Expand Up @@ -135,7 +135,7 @@ private void BeginSendServerHandshake(ServerHandshake handshake, Socket socket)

Task<int>.Factory.FromAsync(socket.BeginSend, socket.EndSend, new[] {segment}, SocketFlags.None, null)
.ContinueWith(t => EndSendServerHandshake())
.ContinueWith(t => FleckLog.Error("Send handshake failed: " + t.Exception.Message), TaskContinuationOptions.OnlyOnFaulted);
.ContinueWith(t => FleckLog.Error("Send handshake failed", t.Exception), TaskContinuationOptions.OnlyOnFaulted);
}

private void EndSendServerHandshake()
Expand Down
3 changes: 1 addition & 2 deletions src/Fleck/Receiver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ public void Receive(DataFrame frame = null)
}, TaskContinuationOptions.NotOnFaulted)
.ContinueWith(t =>
{
if (t.Exception == null) return;
FleckLog.Error(t.Exception.Message);
FleckLog.Error("Recieve failed", t.Exception);
_connection.Close();
}, TaskContinuationOptions.OnlyOnFaulted);
}
Expand Down
3 changes: 1 addition & 2 deletions src/Fleck/Sender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ public void Send(string data)
Task<int>.Factory.FromAsync(Socket.BeginSend, Socket.EndSend, new[] {segment}, SocketFlags.None, null)
.ContinueWith(t =>
{
if (t.Exception == null) return;
FleckLog.Error(t.Exception.Message);
FleckLog.Error("Send failed", t.Exception);
_connection.Close();
}, TaskContinuationOptions.OnlyOnFaulted);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Fleck/WebSocketServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private void ListenForClients()
{
Task<Socket>.Factory.FromAsync(ListenerSocket.BeginAccept, ListenerSocket.EndAccept, null)
.ContinueWith(OnClientConnect)
.ContinueWith(t => FleckLog.Error("Listener socket is closed"), TaskContinuationOptions.OnlyOnFaulted);
.ContinueWith(t => FleckLog.Error("Listener socket is closed", t.Exception), TaskContinuationOptions.OnlyOnFaulted);
}

private void OnClientConnect(Task<Socket> task)
Expand Down

0 comments on commit f47e9ba

Please sign in to comment.