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

Luca Olivetti luca at wetron.es
Fri Dec 13 15:03:44 CET 2019


El 13/12/19 a les 10:38, Michael Van Canneyt via lazarus ha escrit:
> 
> 
> On Fri, 13 Dec 2019, Luca Olivetti via lazarus wrote:
> 
>> Hello,
>>
>> I don't remember if I asked this previously, but it always bugs me.
>>
>> If I do
>>
>>
>> try
>>    AForm.ShowModal
>> except
>> ....
>> end;
>>
>>
>> the exceptions eventually raised in AForm aren't caught by the above 
>> try..except, they always show the default error dialog.
>> I have to use Application.OnException to catch those.
>> Why?
> 
> 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.
I know it doesn't, but I always forget it :-(
Regarding delphi, I stopped using it ten years ago. more or less ;-)

Bye

-- 
Luca Olivetti
Wetron Automation Technology http://www.wetron.es/
Tel. +34 93 5883004 (Ext.3010)  Fax +34 93 5883007


More information about the lazarus mailing list