TsgcHTTP3Client › Events › OnHTTP3Exception
Fires when an exception is raised while processing the HTTP/3 connection.
TsgcHTTP3ExceptionEvent = procedure(Sender: TObject;
const E: Exception) of object;
property OnHTTP3Exception: TsgcHTTP3ExceptionEvent read FOnHTTP3Exception
write FOnHTTP3Exception;
| Name | Type | Description |
|---|---|---|
Sender | TObject | The TsgcHTTP3Client instance that raised the event. |
E | const Exception | The exception. When it is a TsgcHTTP3Exception its ErrorCode property carries the HTTP/3 error code from RFC 9114 Section 8.1, for example h3ecFRAME_ERROR or h3ecMESSAGE_ERROR. |
OnHTTP3Exception surfaces the exception object itself, which is what makes it more useful than OnError: a TsgcHTTP3Exception exposes an ErrorCode that identifies the protocol violation precisely, rather than only a message.
It fires for errors raised while handling the connection, including malformed frames sent by the peer, QPACK decoding failures, and a response body that exceeded MaxResponseSize.
Handle the event to log or classify the failure. Assigning it does not swallow the exception for a synchronous call, which still raises to the caller, so keep the surrounding try..except in place.
procedure TfrmMain.OnHTTP3ExceptionEvent(Sender: TObject; const E: Exception);
begin
if E is TsgcHTTP3Exception then
Log(Format('HTTP/3 error code %d: %s',
[Ord(TsgcHTTP3Exception(E).ErrorCode), E.Message]))
else
Log(E.Message);
end;