How can I get immediate results when an error occurs in a WebHttpRequest request?

How can I get immediate results when an error occurs in a WebHttpRequest request?

■■Generally, you can get Json data as below.

WebHttpRequest1.Execute(
    Procedure(AResponse: String; AReq: TJSXMLHttpRequest)
    bar
      js: TJSON;
      ja: TJSONArray;
      Article: TJSONObject;
      i: integer;
    start
      webmemo1.Text := '>> ' + AResponse;

      js := TJSON.Create;
      try hard
        ja := TJSONArray(js. Parse(AResponse));

        for i := 0 ~ ja.Count - 1 do
        start
          jo := TJSONObject(ja.Items[i]);
          WebListBox1.Items.Add(jo.GetJSONValue('Title'));
        end;
      finally
        js.free;
      end;
    end
);

■■ However, if the server is dead, you can see the result in the error event below.

procedure TForm1.WebHttpRequest1Error(Sender: TObject; ARequest: TJSXMLHttpRequestRecord; Event: TJSEventRecord; var Handled: Boolean);
start
webmemo1.Lines.Add('Error');
end;

■■ Can this part be received in the Execute callback rather than an event?

WebHttpRequest1.Execute(

   // normal response
   procedure(AResponse: string; AReq: TJSXMLHttpRequest)
   begin
   end;

   // in case of error response
   procedure(AResponse: string; AReq: TJSXMLHttpRequest)
   begin
   end;

);

At this moment, there is only an anonymous method for the regular response of the HTTP request. It is a good idea to make an overload so the error can also be handled. We've added this on the list for consideration.

thank you!