TsgcWebSocketProxyServerEvents › OnException

OnException Event

Fires whenever an unhandled exception is raised while processing a downstream connection or its upstream forwarding.

Syntax

property OnException: TsgcExceptionEvent;
// TsgcExceptionEvent = procedure(Connection: TsgcWSConnection; E: Exception) of object

Default Value

Remarks

OnException is raised whenever an exception escapes internal processing, either on the downstream WebSocket side (writing to a socket that the client has already dropped, a user event handler throwing, a failed TCP read...) or on the upstream TCP link the proxy uses to forward data. 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.

Example


procedure OnException(Connection: TsgcWSConnection; E: Exception);
begin
  WriteLn('#exception: ' + E.Message);
end;

Back to Events