Skip to content

Commit

Permalink
Log and disconnect SteamClient if a ClientMsgHandler throws an exception
Browse files Browse the repository at this point in the history
  • Loading branch information
yaakov-h committed Dec 16, 2014
1 parent 6f9a784 commit b0e56ab
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion SteamKit2/SteamKit2/Steam/SteamClient/SteamClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.Threading;
using SteamKit2.Internal;
using System.Diagnostics;
using ProtoBuf;

namespace SteamKit2
{
Expand Down Expand Up @@ -288,7 +289,22 @@ protected override void OnClientMsgReceived( IPacketMsg packetMsg )
// pass along the clientmsg to all registered handlers
foreach ( var kvp in handlers )
{
kvp.Value.HandleMsg( packetMsg );
try
{
kvp.Value.HandleMsg( packetMsg );
}
catch ( ProtoException ex )
{
DebugLog.WriteLine( "SteamClient", "'{0}' handler failed to (de)serialize a protobuf: '{1}'", kvp.Key.Name, ex.Message );
Disconnect();
return;
}
catch ( Exception ex )
{
DebugLog.WriteLine( "SteamClient", "Unhandled '{0}' exception from '{1}' handler: '{2}'", ex.GetType().Name, kvp.Key.Name, ex.Message );
Disconnect();
return;
}
}
}
/// <summary>
Expand Down

0 comments on commit b0e56ab

Please sign in to comment.