Yeah, it seems to be problematic to use this syntax with finally blocks.
Perhaps the optional catch block should be allowed only at the very end,
but it sounds somehow doubtful.

ср, 6 авг. 2025 г. в 16:52, Andreas Heigl <andr...@heigl.org>:

> Hey Mihail
>
> Am 06.08.25 um 13:34 schrieb Mihail Liahimov:
> > Hi!
> >
> > At the moment, I can suggest this syntax:
> >
> > try {
> > // do something
> > } catch (SomeIgnorableException) finally {
> > // do something
> > }
> >
> I find that ... challenging
>
> When reading the code I now have to go to the end of the line to
> understand that the second
>
> // do something
>
> does not belong to the `try` but to the `finally`...
>
>
> And
>
> try {
>    // break stuff
> } catch (SomeIgnorableException)
> finally {
>    // do something regardless
> }
>
> seems boken due to the missing }
>
> But well....
>
> We just have to adapt to something like this:
>
> try {
>    // break stuff
> }
> catch (SomeIgnorableException)
> catch (Some OtherIgnorableException)
> finally {
>    // do something regardless
> }
>
> --
>                                                                ,,,
>                                                               (o o)
> +---------------------------------------------------------ooO-(_)-Ooo-+
> | Andreas Heigl                                                       |
> | mailto:andr...@heigl.org                  N 50°22'59.5" E 08°23'58" |
> | https://andreas.heigl.org                                           |
> +---------------------------------------------------------------------+
> | https://hei.gl/appointmentwithandreas                               |
> +---------------------------------------------------------------------+
> | GPG-Key: https://hei.gl/keyandreasheiglorg                          |
> +---------------------------------------------------------------------+
>
>

Reply via email to