Jump to content
Sign in to follow this  
Joe Sansalone

REST Client: HTTP/1.1 503 Service Unavailable

Recommended Posts

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

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 by Uwe Raabe

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×