Subject: | Explain use of Exception class with Try::Tiny |
Date: | Wed, 13 Feb 2013 23:07:37 +0000 |
To: | "bug-exception-class [...] rt.cpan.org" <bug-exception-class [...] rt.cpan.org> |
From: | Keith Stobie <kstobie [...] tivo.com> |
It would be nice if
Try::Tiny [^] <http://search.cpan.org/%7Edrolsky/Exception-Class-1.36/lib/Exception/Class.pm#___top>
If you are interested in adding try/catch/finally syntactic sugar to your code then I recommend you check out Try::Tiny<http://search.cpan.org/perldoc?Try%3A%3ATiny>. This is a great module that helps you ignore some of the weirdness with eval and $@.
was ammended with what I found at http://www.perlmonks.org/?node_id=998104
Try::Tiny [^] <http://search.cpan.org/%7Edrolsky/Exception-Class-1.36/lib/Exception/Class.pm#___top>
If you are interested in adding try/catch/finally syntactic sugar to your code then I recommend you check out Try::Tiny<http://search.cpan.org/perldoc?Try%3A%3ATiny>. This is a great module that helps you ignore some of the weirdness with eval and $@.
Because Exception::Class->caught() explicitly checks $@ for the exception object with Try::Tiny you simplify this to something like:
catch {
$e = $_;
if(UNIVERSAL::isa($e,'MyException')) {
warn $e->error, "\n";
...
}
}
Show quoted text
________________________________
This email and any attachments may contain confidential and privileged material for the sole use of the intended recipient. Any review, copying, or distribution of this email (or any attachments) by others is prohibited. If you are not the intended recipient, please contact the sender immediately and permanently delete this email and any attachments. No employee or agent of TiVo Inc. is authorized to conclude any binding agreement on behalf of TiVo Inc. by email. Binding agreements with TiVo Inc. may only be made by a signed written agreement.