HttpException exception block not executing & errorcode mapping

Discussion of open issues, suggestions and bugs regarding network security and data protection solution - SecureBridge
Post Reply
JohanDT
Posts: 1
Joined: Thu 25 Aug 2022 13:26

HttpException exception block not executing & errorcode mapping

Post by JohanDT » Thu 25 Aug 2022 13:41

I use delphi 7 and SecureBridge 10.1.1.
Could you please explain to me why the HttpException block is not executed (ignored) but the E: exception block is executed in the following code example:

Try
........
........

CLIResponse:= CLIRequest.GetResponse;

........
........

Except
On E: HttpException Do
Begin
ResponseError:= True;
ErrorCode:= E.Code;
ErrorCode2:= E.HelpContext;
ErrorStr:= E.Message;
End;

on E: Exception do
begin
ResponseError:= True;
ErrorStr:= HttpException(E).Message;
ErrorCode:= Ord(HttpException(E).StatusCode);
ErrorCode2:= HttpException(E).Code;
end;
End;

Even if the On E: Exception block is removed the on E: HttpException does not excecute
On a disconnected internet connection it returns for instance:

ErrorCode= 64
ErrorCode2= 0
ErrorStr=
Unknown host 'uatsim.imbeko.live'.
Socket Error Code: 11001($2AF9)

On a request timeout it returns:

ErrorCode= 64
ErrorCode2= 0
ErrorStr=
Error on data reading from the connection:
An existing connection was forcibly closed by the remote host

I need to be able to get an accurate TScHttpStatusCode to be able to map the error (64) to a specific action to take. When catching the normal on E: exception it returns the same error code for both instances. The errorcode 64 can not be linked to the ordinal value of the TScHttpStatusCode as it falls outside the range of 0-47 (scAccepted .. scUnknown).

It is important to get the corrrect HttPexception statuscode in order to perform different actions for different exceptions

Post Reply