TsgcQUICServer › Events › OnQUICException

OnQUICException Event

Fires when an unhandled exception occurs while servicing a QUIC connection or the listener.

Syntax

property OnQUICException: TsgcQUICServerExceptionEvent;
// TsgcQUICServerExceptionEvent = procedure(Sender: TObject; const aConnection: TsgcQUICServerConnection; const aException: Exception) of object

Default Value

—

Parameters

NameTypeDescription
SenderTObjectThe TsgcQUICServer instance.
aConnectionconst TsgcQUICServerConnectionThe connection being serviced when the error occurred, or nil for a listener-level error. Test it before use, see the Remarks.
aExceptionExceptionThe trapped exception. It is freed once the handler returns, so copy anything you need to keep.

Remarks

OnQUICException is raised when the server's background listener thread traps an exception on a pass of the QUIC event loop, that is, while pumping events, accepting connections, advancing handshakes, reading streams, or inside one of your own event handlers (a handler that raises is caught here, not propagated). The server swallows the exception and keeps running, so handling this event is the only way to notice such a failure.

Check aConnection for nil rather than assuming either case. A failure raised while reading a specific connection carries that connection, so you can log or drop the session it belongs to. A failure raised by the listener itself (the pump and accept guard) has no connection context, and reports nil. The .NET implementation makes the same split, filling the parameter in when the error is attributable to a connection and passing null for accept-loop failures.

Exceptions raised by Start itself do not arrive here. Start runs on the caller's thread and raises directly, so wrap it in a try..except to catch configuration errors such as a missing certificate or an OpenSSL that is too old.

This event runs on the server's background listener thread, so marshal to the main thread before touching the UI.

Example


procedure OnQUICExceptionEvent(Sender: TObject; const aConnection: TsgcQUICServerConnection; const aException: Exception);
begin
  // nil means the listener failed, not one session
  if Assigned(aConnection) then
    Log(Format('QUIC error on connection created at %s: %s',
      [DateTimeToStr(aConnection.CreatedAt), aException.Message]))
  else
    Log('QUIC listener error: ' + aException.Message);
end;

Back to Events