NAME
Data::Object::Role::Tryable
ABSTRACT
Data-Object Tryable Role
SYNOPSIS
use Data::Object::Class;
use Data::Object::Role::Tryable;
my $try = $self->try($method);
$try->catch($type, fun ($caught) {
# caught an exception
return $something;
});
$try->default(fun ($caught) {
# catch the uncaught
return $something;
});
$try->finally(fun ($self, $caught) {
# always run after try/catch
});
my $result = $try->result;
DESCRIPTION
This role provides a wrapper around the Data::Object::Try class which provides an object-oriented interface for performing complex try/catch operations.
LIBRARIES
This package uses type constraints defined by:
METHODS
This package implements the following methods.
try
try(Str | CodeRef $method) : Object
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 example
-
my $try; $try = $self->try($method); $try = $self->try(fun ($self) { # do something return $something; });
CREDITS
Al Newkirk, +319
Anthony Brummett, +10
Adam Hopkins, +2
José Joaquín Atria, +1
AUTHOR
Al Newkirk, awncorp@cpan.org
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 here, https://github.com/iamalnewkirk/do/blob/master/LICENSE.
PROJECT
SEE ALSO
To get the most out of this distribution, consider reading the following: