Data-Object-Try
view release on metacpan or search on metacpan
lib/Data/Object/Try.pm view on Meta::CPAN
=item no_finally example #1
use routines;
my $try = Data::Object::Try->new(
invocant => Example->new,
arguments => [1,2,3]
);
$try->call(fun (@args) {
return $try;
});
$try->finally(fun (@args) {
$try->{'$finally'} = [@args];
});
$try->no_finally;
=back
=cut
=head2 no_try
no_try() : Object
The no_try method removes any configured C<try> operation and returns the
object.
=over 4
=item no_try example #1
use routines;
my $try = Data::Object::Try->new;
$try->call(fun (@args) {
return [@args];
});
$try->no_try;
=back
=cut
=head2 result
result(Any @args) : Any
The result method executes the try/catch/default/finally logic and returns
either 1) the return value from the successfully tried operation 2) the return
value from the successfully matched catch condition if an exception was thrown
3) the return value from the default catch condition if an exception was thrown
and no catch condition matched. When invoked, the C<try> and C<finally>
callbacks will received an C<invocant> if one was provided to the constructor,
the default C<arguments> if any were provided to the constructor, and whatever
arguments were passed directly to this method.
=over 4
=item result example #1
use routines;
my $try = Data::Object::Try->new;
$try->call(fun (@args) {
return [@args];
});
$try->result;
=back
=over 4
=item result example #2
use routines;
my $try = Data::Object::Try->new;
$try->call(fun (@args) {
return [@args];
});
$try->result(1..5);
=back
=cut
=head1 AUTHOR
Al Newkirk, C<awncorp@cpan.org>
=head1 LICENSE
Copyright (C) 2011-2019, Al Newkirk, et al.
This is free software; you can redistribute it and/or modify it under the terms
of the The Apache License, Version 2.0, as elucidated in the L<"license
file"|https://github.com/iamalnewkirk/data-object-try/blob/master/LICENSE>.
=head1 PROJECT
L<Wiki|https://github.com/iamalnewkirk/data-object-try/wiki>
L<Project|https://github.com/iamalnewkirk/data-object-try>
L<Initiatives|https://github.com/iamalnewkirk/data-object-try/projects>
L<Milestones|https://github.com/iamalnewkirk/data-object-try/milestones>
( run in 0.586 second using v1.01-cache-2.11-cpan-39bf76dae61 )