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.