Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2018-10

Exception handling in Linux?

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bo Berglund

I am working on a port of a Windows Win32 command line program (Delphi
2007) to Linux Ubuntu 18.04 64bit.

I am almost done now and my tests show that the basic functionality works as intended.
But I am not sure about the exception handling at all...

In my code I have many instances of:
try
  some code block
except
  on E: Exception do
  begin
    LogDebug('Exception in module xxxx: ' + E.Message;
  end
end;

Now when testing I have experienced that Lazarus trows up an exception dialog when code inside such a construct is running (it typically comes from some Indy10 operation). When I hit Continue I expect the code to run the except block but it does not.
There are no log messages concerning the exception....

So I wonder if this is a difference between Windows and Linux or some missing configuration setting on my part?

Bo Berglund Developer in Sweden

Reply by email

leledumbo
to Bo Berglund
Now when testing I have experienced that Lazarus trows up an exception

dialog when code inside such a construct is running

The debugger by default catches all exceptions, handled or not, because it catches the exception before your handler (the except block). Configure exceptions to ignore in debugger options.

When I hit Continue I expect the code to run the except block but it does not.

There are too many possibilities, if you set a breakpoint in the LogDebug statement, after pressing continue, does the debugger stop there?

Reply by email

Santiago A.
to Bo Berglund: I am working on a port of a Windows Win32 command line program (Delphi 2007) to Linux…
Bo Berglund wrote 27 lines
I am working on a port of a Windows Win32 command line program (Delphi 2007) to Linux Ubuntu 18.04 64bit. I am almost done now and my tests show that the basic functionality works as intended. But I am not sure about the exception handling at all... In my code I have many instances of: try some code block except on E: Exception do begin LogDebug('Exception in module xxxx: ' + E.Message; end end; Now when testing I have experienced that Lazarus trows up an exception dialog when code inside such a construct is running (it typically comes from some Indy10 operation). When I hit Continue I expect the code to run the except block but it does not. There are no log messages concerning the exception.... So I wonder if this is a difference between Windows and Linux or some missing configuration setting on my part?

Do you get that exception dialog when you run the executable out of the IDE environment?

I mean, maybe the exception is handled inside indy10, so it is not propagated to the level of your except block. My theory is that the exception dialog is raised by Lazarus environment whenever an exception is raised, handled or not, and if you click "continue", then Indy10 handles it.

Saludos Santiago A.

Reply by email

Bo Berglund
to Santiago A.
"Santiago A. wrote 8 lines
Do you get that exception dialog when you run the executable out of the IDE environment? I mean, maybe the exception is handled inside indy10, so it is not propagated to the level of your except block. My theory is that the exception dialog is raised by Lazarus environment whenever an exception is raised, handled or not, and if you click "continue", then Indy10 handles it.

I think you are probably right. After I checked the box in the dialog the exception does not show up again...

Bo Berglund Developer in Sweden

Reply by email