Data::Object::Role::Tryable
Tryable Role for Perl 5
package Example; use Moo; with 'Data::Object::Role::Tryable'; package main; use routines; my $example = Example->new;
This package provides a wrapper around the Data::Object::Try class which provides an object-oriented interface for performing complex try/catch operations.
This package implements the following methods:
try(CodeRef | Str $method) : InstanceOf['Data::Object::Try']
The try method takes a method name or coderef and returns a Data::Object::Try object with the current object passed as the invocant which means that try and finally callbacks will receive that as the first argument.
try
finally
# given: synopsis my $tryer = $example->try(fun(@args) { [@args] }); # $tryer->result(...)
# given: synopsis my $tryer = $example->try(fun(@args) { die 'tried'; }); $tryer->default(fun($error) { return ['tried'] if $error =~ 'tried'; return [$error]; }); # $tryer->result(...)
Al Newkirk, awncorp@cpan.org
awncorp@cpan.org
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 "license file".
Wiki
Project
Initiatives
Milestones
Contributing
Issues
To install Data::Object::Role::Tryable, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Object::Role::Tryable
CPAN shell
perl -MCPAN -e shell install Data::Object::Role::Tryable
For more information on module installation, please visit the detailed CPAN module installation guide.