[Lazarus] try..except doesn't trap exception in Form.Showmodal

Michael Van Canneyt michael at freepascal.org
Fri Dec 13 15:10:31 CET 2019



On Fri, 13 Dec 2019, Luca Olivetti via lazarus wrote:

>> 
>> Because ShowModal must run the application message loop, and that 
>> already catches the
>> exceptions.  This is in line with the event-based architecture. It's the 
>> same in Delphi.
>
> Yes, I would expect that with Show, but ShowModal is blocking, so I 
> would expect the try..except to work.

Yes, but ShowModal is not actually "blocking".

It fakes this 'blocking' by running the message loop (which is asynchronous by nature).
If an exception occurs, it is in an event handler, which, from the
application point of view, is asynchronous.

It's more like threads. Exceptions in threads are also not propagated to the
main thread.

At least, that is how I see it. 
Not 100% accurate, but it does the trick for my understanding ;-)

Michael.


More information about the lazarus mailing list