Is there a more succinct way to lift a thrown Exception to a Failure than the following?
try {
die 'always';
CATCH { default { fail $_ } }
}
Here's a more succinct version of moritz' code.
(try something()) orelse fail $!;
try something();
fail $! if $!;
Note that CATCH
blocks apply to all statements in the same scope, even to code after the CATCH
block. So if you want to use CATCH blocks, be careful about keeping the scope small.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With