TsgcHTTP3Server › Events › OnH3Exception
Fires when an unhandled exception occurs while serving an HTTP/3 connection.
property OnH3Exception: TsgcQUICServerExceptionEvent;
// TsgcQUICServerExceptionEvent = procedure(Sender: TObject; const aConnection: TsgcQUICServerConnection; const aException: Exception) of object
—
| Name | Type | Description |
|---|---|---|
Sender | TObject | The TsgcHTTP3Server instance that raised the event. |
aConnection | const TsgcQUICServerConnection | QUIC connection on which the exception was raised. May be nil for errors that are not tied to a single connection. In .NET this parameter is a string holding the peer endpoint, empty for listener-level errors. |
aException | Exception | The exception that was caught. It is a TsgcHTTP3Exception when an HTTP/3 conformance rule was violated, and its ErrorCode property then carries the HTTP/3 error code that dropped the connection. |
OnH3Exception is raised when an exception occurs while the server processes QUIC/HTTP/3 traffic for a connection, for example during the handshake, frame parsing, request dispatch or response writing. Handling the event lets the application log the failure and keep the server running, since the error is isolated to the affected connection rather than terminating the listener.
The most useful case is a protocol violation by the peer. When a client breaks an RFC 9114 rule, the server raises a TsgcHTTP3Exception carrying the HTTP/3 error code (for example h3ecFRAME_UNEXPECTED or h3ecMESSAGE_ERROR), the connection is dropped with that code, and the exception surfaces here so the reason is observable. Cast aException to TsgcHTTP3Exception to read the code:
Note that the event does not see every error. A malformed peer stream that is not a conformance violation is swallowed so it cannot crash the server, and an exception raised inside an OnH3TunnelData handler is discarded rather than reported here.
The event is raised on the server's background listener thread, so it must not touch the UI directly. Read aException.Message for the error detail, and use aConnection to identify the peer when it is available.
procedure OnH3ExceptionEvent(Sender: TObject; const aConnection:
TsgcQUICServerConnection; const aException: Exception);
begin
if aException is TsgcHTTP3Exception then
Log('HTTP/3 protocol error, code ' +
IntToStr(GetH3ErrorCodeValue(TsgcHTTP3Exception(aException).ErrorCode)) +
': ' + aException.Message)
else
Log('HTTP/3 error: ' + aException.Message);
end;