Discussion:
[Lazarus] Exception handling in Linux?
Bo Berglund via Lazarus
2018-10-25 16:46:11 UTC
Permalink
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

--
leledumbo via Lazarus
2018-10-26 04:46:11 UTC
Permalink
Post by Bo Berglund via Lazarus
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.
Post by Bo Berglund via Lazarus
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?



--
Sent from: http://free-pascal-lazarus.989080.n3.nabble.com/
--
Santiago A. via Lazarus
2018-10-26 10:50:34 UTC
Permalink
Post by Bo Berglund via Lazarus
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...
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.

--
Bo Berglund via Lazarus
2018-10-30 22:43:33 UTC
Permalink
On Fri, 26 Oct 2018 12:50:34 +0200, "Santiago A. via Lazarus"
Post by Santiago A. via Lazarus
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

--
Loading...