diff --git a/HTTP/HttpServer.cs b/HTTP/HttpServer.cs index 3b21370..928567a 100644 --- a/HTTP/HttpServer.cs +++ b/HTTP/HttpServer.cs @@ -50,6 +50,11 @@ public sealed class HttpServer /// public event Action? OnResponse; + /// + /// Called when a request causes an exception. + /// + public event Action? OnException; + /// /// The maximum time the socket may be inactive before it is presumed dead and closed. /// @@ -179,12 +184,12 @@ public sealed class HttpServer await new HttpResponse(400, e.Message).WriteTo(httpStream).WaitAsync(Timeout); } catch { } - break; + throw; } catch (TimeoutException) { //Timeout - break; + throw; } catch (IOException) { @@ -203,10 +208,11 @@ public sealed class HttpServer } } } - catch (Exception) + catch (Exception e) { //Swallow exceptions to prevent the server from crashing. //When debugging, use a debugger to break on exceptions. + OnException?.Invoke(endpoint, e); } finally {