TsgcQUICClient › Events › OnQUICException

OnQUICException Event

Fires when an exception is raised on the QUIC connection so the application can handle it instead of losing it.

Syntax

property OnQUICException: TsgcQUICExceptionEvent;

// TsgcQUICExceptionEvent = procedure(Sender: TObject;
//   const Connection: TsgcQUICConnection; const E: Exception) of object;

Parameters

NameTypeDescription
SenderTObjectThe TsgcQUICClient instance that raised the event.
Connectionconst TsgcQUICConnectionThe connection the exception relates to. May be nil when the failure happened before a connection object existed. In .NET the parameter is a TsgcQUICClientConnection and may be null.
Econst ExceptionThe exception that was raised. Read E.Message for the detail. Do not free it, and do not re-raise it from the handler.

Remarks

OnQUICException is where the component surfaces failures it caught rather than letting them escape. Connection failures are the main case: setting Active to True, or calling Connect, Start or Stop, catches any exception, marks the connection disconnected and raises this event. Socket errors on the underlying UDP transport arrive here too. Because those calls do not re-raise, handling this event is the only way to learn why a connect failed, Connect merely returns False.

Typical causes worth logging: OpenSSL could not be loaded or is too old for QUIC, the TLS handshake failed or timed out (see SSLQUICOptions.ConnectTimeout), certificate validation was rejected, or the UDP socket could not be bound.

The event may be raised from the connection read thread or from the background thread used by Start and Stop. The component sets NotifyEvents to neNoSync, so the handler does not run on the main thread: never touch VCL or FMX controls directly from it, marshal to the main thread instead.

Example


oClient.OnQUICException := OnQUICExceptionEvent;

if not oClient.Connect then
  Log('connect failed, see the exception handler for the reason');

procedure OnQUICExceptionEvent(Sender: TObject; const Connection: TsgcQUICConnection;
  const E: Exception);
begin
  Log('QUIC error: ' + E.ClassName + ': ' + E.Message);
end;

Back to Events