TsgcHTTP3Client › Events › OnHTTP3Exception

OnHTTP3Exception Event

Fires when an exception is raised while processing the HTTP/3 connection.

Syntax

TsgcHTTP3ExceptionEvent = procedure(Sender: TObject;

  const E: Exception) of object;



property OnHTTP3Exception: TsgcHTTP3ExceptionEvent read FOnHTTP3Exception

  write FOnHTTP3Exception;

Parameters

NameTypeDescription
SenderTObjectThe TsgcHTTP3Client instance that raised the event.
Econst ExceptionThe 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.

Remarks

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.

Example



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;

Back to Events