Re: [twsocket] THttpCli.CtrlSocket.OnBgException

2008-04-07 Thread Wilfried Mestdagh
Hello crazdcodr,

I don't see complaints but here is an example.

procedure CtrlSocketBgException(Sender: TObject; E: Exception;
  var CanClose: boolean);

HttpCli1.CtrlSocket.OnBgException := CtrlSocketBgException;

procedure TForm1.CtrlSocketBgException(Sender: TObject; E: Exception;
  var CanClose: boolean);
begin
  CanClose := True;
  // Log it
  // Do what you must do according to application if this happens
end;

---
Rgds, Wilfried [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html
http://www.mestdagh.biz

Monday, April 7, 2008, 02:23, [EMAIL PROTECTED] wrote:

 I have tried to implement an exception handler for this event but was
 unsuccessful. I have also read of similar complaints from other people. A
 working example of how to do this would be greatly appreciated.

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] THttpCli.CtrlSocket.OnBgException

2008-04-07 Thread Arno Garrels
[EMAIL PROTECTED] wrote:
 I have tried to implement an exception handler for this event but was
 unsuccessful. 

Due to the asynchrone nature of ICS you cannot catch and handle all 
possible exceptions where they occured as usual, those are called 
background exceptions.

For instance:

try
   GetAsync;
except
   do something; 
end; 

When GetAsync returns the try-block is left. Unhandled exceptions that
occur afterwards and before your next event handler would trigger 
OnBgException where you should inspect the exception object and decide
what to do next, OnBgException may also trigger when an unhandled 
exception occured in one of your event handlers, so it's important to
ensure that no unhandled exception raise in an event handler. If 
OnBgException is not assigned background exceptions are silently eaten.

The THttpCli intruduces EHttpException with a error number: 
{ EHttpException error code }
httperrNoError  = 0;
httperrBusy = 1;
httperrNoData   = 2;
httperrAborted  = 3;
httperrOverflow = 4;
httperrVersion  = 5;
httperrInvalidAuthState = 6;
httperrSslHandShake = 7;

Search vor EHttpException in OverbyteIcsHttpProt.pas.

--
Arno Garrels [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html


-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be