Joe Sansalone 6 Posted December 11, 2021 Hi, Using Rest Client components. Shouldn't EHTTPProtocolException catch a HTTP/1.1 503 Service Unavailable? I expected that a 500 unavailable error would raise a EHTTPProtocolException. But instead, the below code did NOT catch that error and my higher level code caught it .. but it's not the behavior I wanted. I need to catch it locally. Is this a bug? My alternative is to broaden the Exception that I catch locally. Joe ======================= code ===================================== try FRESTRequest.Execute; except on E:EHTTPProtocolException do begin if Assigned(FLog) then FLog.WriteTimeStamp(lctHTTP, lptImportant, 'ModifyCall API: error executing request'); result := false; raise ETwilioCallError.Create('HTTP protocol exception'); end; end; Share this post Link to post
Uwe Raabe 2057 Posted December 11, 2021 (edited) Have a look into the except block of TCustomRESTRequest.Execute and you can see that it catches any EHTTPProtocolException and raises a simple ERESTException for errors >= 500 when this is enabled (it is by default). So you either catch ERESTException or (what I suggest) disable RaiseExceptionOn500 in the TRESTClient and wire OnHTTPProtocolError instead. Edited December 11, 2021 by Uwe Raabe 1 Share this post Link to post