TsgcHTTP_API_OpenAIEvents › OnHTTPAPIException

OnHTTPAPIException Event

Fires when an uncaught exception is raised during an OpenAI REST call

Syntax

property OnHTTPAPIException: TsgcHTTPAPIExceptionEvent;
// TsgcHTTPAPIExceptionEvent = procedure(Sender: TObject; E: Exception) of object

Default Value

Remarks

Triggered whenever an exception propagates out of any of the REST wrappers (Chat Completions, Responses, Images, Audio, Embeddings, etc.) before it reaches the caller. Typical causes are network failures, TLS handshake errors, HTTP status codes returned as exceptions, and malformed JSON payloads. Inspect E.ClassName and E.Message to log or transform the error, and optionally re-raise from your handler if you want the caller to see it. Use this event as a single centralized place to surface diagnostics from every OpenAI endpoint.

Example

procedure TForm1.oAPIHTTPAPIException(Sender: TObject; E: Exception);
begin
  ShowMessage('OpenAI error [' + E.ClassName + ']: ' + E.Message);
end;

Back to Events