Browse Source

just log useful exceptions

tags/2.3
clowwindy 10 years ago
parent
commit
e13d2287aa
2 changed files with 40 additions and 13 deletions
  1. +13
    -13
      shadowsocks-csharp/Controller/Local.cs
  2. +27
    -0
      shadowsocks-csharp/Controller/Logging.cs

+ 13
- 13
shadowsocks-csharp/Controller/Local.cs View File

@@ -144,7 +144,7 @@ namespace Shadowsocks.Controller
}
catch (Exception e)
{
Console.WriteLine(e);
Logging.LogUsefulException(e);
this.Close();
}
}
@@ -176,7 +176,7 @@ namespace Shadowsocks.Controller
}
catch (Exception e)
{
Console.WriteLine(e);
Logging.LogUsefulException(e);
}
}
if (remote != null)
@@ -188,7 +188,7 @@ namespace Shadowsocks.Controller
}
catch (SocketException e)
{
Console.WriteLine(e);
Logging.LogUsefulException(e);
}
}
lock (encryptionLock)
@@ -218,7 +218,7 @@ namespace Shadowsocks.Controller
}
catch (Exception e)
{
Console.WriteLine(e);
Logging.LogUsefulException(e);
this.Close();
}
}
@@ -236,7 +236,7 @@ namespace Shadowsocks.Controller
}
catch (Exception e)
{
Console.WriteLine(e);
Logging.LogUsefulException(e);
this.Close();
}
}
@@ -269,7 +269,7 @@ namespace Shadowsocks.Controller
}
catch (Exception e)
{
Console.WriteLine(e);
Logging.LogUsefulException(e);
this.Close();
}
}
@@ -296,7 +296,7 @@ namespace Shadowsocks.Controller
}
catch (Exception e)
{
Console.WriteLine(e);
Logging.LogUsefulException(e);
this.Close();
}
}
@@ -324,7 +324,7 @@ namespace Shadowsocks.Controller
}
catch (Exception e)
{
Console.WriteLine(e);
Logging.LogUsefulException(e);
this.Close();
}
}
@@ -346,7 +346,7 @@ namespace Shadowsocks.Controller
}
catch (Exception e)
{
Console.WriteLine(e);
Logging.LogUsefulException(e);
this.Close();
}
}
@@ -384,7 +384,7 @@ namespace Shadowsocks.Controller
}
catch (Exception e)
{
Console.WriteLine(e);
Logging.LogUsefulException(e);
this.Close();
}
}
@@ -421,7 +421,7 @@ namespace Shadowsocks.Controller
}
catch (Exception e)
{
Console.WriteLine(e);
Logging.LogUsefulException(e);
this.Close();
}
}
@@ -440,7 +440,7 @@ namespace Shadowsocks.Controller
}
catch (Exception e)
{
Console.WriteLine(e);
Logging.LogUsefulException(e);
this.Close();
}
}
@@ -459,7 +459,7 @@ namespace Shadowsocks.Controller
}
catch (Exception e)
{
Console.WriteLine(e);
Logging.LogUsefulException(e);
this.Close();
}
}


+ 27
- 0
shadowsocks-csharp/Controller/Logging.cs View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Sockets;
using System.Text;
namespace Shadowsocks.Controller
@@ -30,5 +31,31 @@ namespace Shadowsocks.Controller
return false;
}
}
public static void LogUsefulException(Exception e)
{
// just log useful exceptions, not all of them
if (e is SocketException)
{
SocketException se = (SocketException)e;
if (se.SocketErrorCode == SocketError.ConnectionAborted)
{
// closed by browser when sending
// normally happens when download is canceled or a tab is closed before page is loaded
}
else if (se.SocketErrorCode == SocketError.ConnectionReset)
{
// received rst
}
else
{
Console.WriteLine(e);
}
}
else
{
Console.WriteLine(e);
}
}
}
}

Loading…
Cancel
Save