in reply to Re: Try::Tiny - return in catch from sub
in thread Try::Tiny - return in catch from sub

um, it says what try returns, what catch returns ... see this example
try { die_sometimes(); } catch { # ...code run in case of error } finally { if (@_) { print "The try block died with: @_\n"; } else { print "The try block ran without error.\n"; } };
if you want to return from your sub from within a try/catch then use as directed
use TryCatch; sub foo { my ($self) = @_; try { die Some::Class->new(code => 404 ) if $self->not_found; return "return value from foo"; } catch (Some::Class $e where { $_->code > 100 } ) { } }
Try::Tiny is for when TryCatch is too much, it is not a drop in replacement, mind the caveats

Replies are listed 'Best First'.
Re^3: Try::Tiny - return in catch from sub
by mjscott2702 (Pilgrim) on Nov 26, 2010 at 15:34 UTC
    um, not in the CPAN documentation:

    This module provides bare bones try/catch/finally statements that are designed to minimize common mistakes with eval blocks, and NOTHING else. This is unlike TryCatch which provides a nice syntax and avoids adding another call stack layer, and supports calling return from the try block to return from the parent subroutine.

      That says Try::Tiny does not support returning from try/catch/finally blocks like TryCatch, its how they're different