TsgcWebSocketHTTPServer › Events › OnException
Fires whenever an unhandled exception is raised while processing a client connection.
public event TsgcExceptionEventHandler OnException;
// delegate void TsgcExceptionEventHandler(TsgcWSConnection Connection, Exception E)
—
OnException is raised whenever an exception escapes internal processing, either on the WebSocket side or while dispatching an HTTP request (OnCommandGet/OnCommandOther, session management, static file serving, HTTP/2 streaming...). The E parameter exposes the exception instance so the application can log the message or react to specific classes. By default a disconnection raises an exception here; set Options.RaiseDisconnectExceptions to False to suppress those disconnect-related exceptions. For HTTP requests the server still returns a 500 response to the client even when the handler logs or swallows the error.
void OnException(TsgcWSConnection Connection, Exception E)
{
Console.WriteLine("#exception: " + E.Message);
}