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

Michael Van Canneyt michael at freepascal.org
Fri Dec 13 10:38:05 CET 2019



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.

Michael.



More information about the lazarus mailing list