Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to catch OleObject exception in Inno Setup?

So I try to make a post request having no internet connection using next modified code:

      WinHttpReq := CreateOleObject('WinHttp.WinHttpRequest.5.1');
      WinHttpReq.Open('POST', '<your_web_server>', false);
      WinHttpReq.SetRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
      try
        WinHttpReq.Send('data');
      except
           bla:= 'e';
      finally
           bla := 'f';
      end;

Yet exception does not get catched and I get crush of my setup application with next image:

enter image description here

How to handle OleObject exception in Inno Setup?

like image 744
DuckQueen Avatar asked Mar 20 '23 10:03

DuckQueen


1 Answers

Your code is incomplete, but try..except block catches all the exceptions, including those thrown by OLE objects. However, your screenshot shows the line number, where the exception was thrown, and so you were running debugger.

And debugger shows all exception messages regardless they are in a try..except block, unless you uncheck "Pause on exceptions" option in Inno Setup IDE settings:

enter image description here

By default is this option enabled (which I would recommend to keep), which means that all exceptions are reported as exception messages and that's what might have mislead you. If you were running your setup without debugger attached, you wouldn't see that exception message.

like image 193
TLama Avatar answered Apr 09 '23 16:04

TLama