From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Exception Handling within Gtkada
Date: Tue, 21 Sep 2021 09:40:49 +0200 [thread overview]
Message-ID: <sic2a0$qli$1@gioia.aioe.org> (raw)
In-Reply-To: 002f7e98-baca-40a3-85f1-211b77550bc7n@googlegroups.com
On 2021-09-21 09:24, Emmanuel Briot wrote:
>>> Generally, Ada exceptions must not left scope of callback function. Thus, such code should be added to each callback/event handler/etc. subprogram of your application.
>> Right. Each handler should end like this:
>
> We were talking the other day of the high-level Connect subprograms generated by GtkAda (`Gtk.Button.On_Clicked` and so on). Those will always catch exceptions and avoid propagating them to the C layer in gtk+ (which as Dmitry mentions is dangerous). They will in effect call `GtkAda.Bindings.Process_Exception`, which in turns calls a user-defined subprogram, see GtkAda.Bindings.Set_On_Exceptions
Very cool.
> I think this should be the recommended approach for general exceptions. Of course, your callbacks should directly handle exceptions that they know how to recover from, and deal with that locally.
Yes, but Ada does that much better. I mean rendezvous, which is Ada's
idea of an event handling. An exception in a rendezvous propagates to
the caller. For a GUI it would mean that if a callback fails the emitter
of the signal gets an exception, which would be the right place to
handle the issue rather than sweeping it under the rug.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2021-09-21 7:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <nnd$672ea4c3$361caa01@549d065034cf3e10>
2021-09-21 6:49 ` Exception Handling within Gtkada Vadim Godunko
2021-09-21 7:01 ` Dmitry A. Kazakov
2021-09-21 7:24 ` Emmanuel Briot
2021-09-21 7:40 ` Dmitry A. Kazakov [this message]
2021-09-22 8:42 ` ldries46
2021-09-22 10:22 ` Dmitry A. Kazakov
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox