Subject: | Enhancement: Have "cuddled-else" logic applied to try/catch/finally blocks |
Currently, try/catch/finally blocks are not recognized the way
if/elsif/else blocks are, and lead to inconsistent line-breaks when
--cuddled-else is set. It would be nice if they were cuddled as well.
See the attached files: first file (t.pl) is a short example with both an
if-block and a try-block. Second file (t.pl.tdy) is what it currently
looks like after perltidy. Third file (t.pl.tdy2) is what I think it
should look like.
This could be tricky, as there are competing exception-handling packages
on CPAN, some with slightly different syntax. Try::Tiny, for example,
does not take a class name after "catch", and only offers
try/catch/finally. Error, in contrast, takes a class name after "catch",
and offers try, catch, except, otherwise and finally.
Randy
--
Randy J. Ray
rjray@blackperl.com
randy.j.ray@gmail.com
Subject: | t.pl.tdy |
Message body not shown because it is not plain text.
Subject: | t.pl |
#!/usr/bin/env perl
use strict;
use warnings;
use Error qw(:try);
sub foo {
if (1) {
do_something();
} else {
do_something_else();
}
try {
something();
} catch Error with {
something_else();
} finally {
foo();
}
}
Subject: | t.pl.tdy2 |
Message body not shown because it is not plain text.