catch exceptions differently if we are debugging
This commit is contained in:
parent
38bf02d406
commit
04dabc6455
@ -1,4 +1,5 @@
|
|||||||
using System.Net;
|
using System.Diagnostics;
|
||||||
|
using System.Net;
|
||||||
using System.Net.Security;
|
using System.Net.Security;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Security.Authentication;
|
using System.Security.Authentication;
|
||||||
@ -386,27 +387,56 @@ public class WebServer
|
|||||||
{
|
{
|
||||||
// Console.WriteLine("Client connected");
|
// Console.WriteLine("Client connected");
|
||||||
|
|
||||||
try
|
if (Debugger.IsAttached)
|
||||||
{
|
{
|
||||||
HandleClient(client);
|
// do not catch generic exceptions when running under a debugger
|
||||||
|
try
|
||||||
|
{
|
||||||
|
HandleClient(client);
|
||||||
|
}
|
||||||
|
catch (System.Net.Sockets.SocketException ex)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine("caught SocketException; ignoring");
|
||||||
|
Console.Error.WriteLine(ex.Message);
|
||||||
|
}
|
||||||
|
catch (System.IO.IOException ex)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine("caught IOException; ignoring");
|
||||||
|
Console.Error.WriteLine(ex.Message);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine("caught exception of type {0}", ex.GetType().FullName);
|
||||||
|
Console.Error.WriteLine(ex.Message);
|
||||||
|
Console.Error.WriteLine(ex.StackTrace);
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
catch (System.Net.Sockets.SocketException ex)
|
else
|
||||||
{
|
{
|
||||||
Console.Error.WriteLine("caught SocketException; ignoring");
|
// also catch generic exceptions if we are not debugging
|
||||||
Console.Error.WriteLine(ex.Message);
|
try
|
||||||
|
{
|
||||||
|
HandleClient(client);
|
||||||
|
}
|
||||||
|
catch (System.Net.Sockets.SocketException ex)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine("caught SocketException; ignoring");
|
||||||
|
Console.Error.WriteLine(ex.Message);
|
||||||
|
}
|
||||||
|
catch (System.IO.IOException ex)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine("caught IOException; ignoring");
|
||||||
|
Console.Error.WriteLine(ex.Message);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine("caught exception of type {0}", ex.GetType().FullName);
|
||||||
|
Console.Error.WriteLine(ex.Message);
|
||||||
|
Console.Error.WriteLine(ex.StackTrace);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (System.IO.IOException ex)
|
|
||||||
{
|
|
||||||
Console.Error.WriteLine("caught IOException; ignoring");
|
|
||||||
Console.Error.WriteLine(ex.Message);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Console.Error.WriteLine("caught exception of type {0}", ex.GetType().FullName);
|
|
||||||
Console.Error.WriteLine(ex.Message);
|
|
||||||
Console.Error.WriteLine(ex.StackTrace);
|
|
||||||
}
|
|
||||||
|
|
||||||
client.Close();
|
client.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user