Why not adopt me?
NAME
Try - nicer exception handling syntax
VERSION
version 0.03
SYNOPSIS
try {
die "foo";
}
catch {
when (/foo/) {
warn "Caught foo";
}
}
DESCRIPTION
This module implements a try/catch/finally statement. It is based heavily on (and mostly implemented via) Try::Tiny. The differences are:
It is a statement.
my $foo = try { ... }
doesn't work anymore, but in return, you don't have to remember the trailing semicolon anymore.eval
still works fine if you need an expression (in 5.14+ at least).The blocks are ordered, and only one catch and finally block are supported.
try { } finally { } catch { }
andtry { } catch { } finally { } finally { }
do not work with this module, mostly because that's just extra complexity for no real purpose.catch
andfinally
are no longer exported - they are just part of the syntax of thetry
statement. This is almost certainly not an issue.
EXPORTS
try
try
takes a block to run, and catch exceptions from. The block can optionally be followed by catch
and another block and finally
and another block. The catch
block is run when the try
block throws an exception, and the exception thrown will be in both $_
and @_
. The finally
block will be run after the try
and catch
blocks regardless of what happens, even if the catch
block rethrows the exception. The exception thrown will be in @_
but not $_
(this may change in the future, since I'm pretty sure the reasoning for this is no longer useful in 5.14).
BUGS
No known bugs.
Please report any bugs through RT: email bug-try at rt.cpan.org
, or browse to http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Try.
SEE ALSO
SUPPORT
You can find this documentation for this module with the perldoc command.
perldoc Try
You can also look for information at:
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
RT: CPAN's request tracker
Search CPAN
AUTHOR
Jesse Luehrs <doy at cpan dot org>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2013 by Jesse Luehrs.
This is free software, licensed under:
The MIT (X11) License