| 1 | # Copyright (c) 2017 by Pali <pali@cpan.org> | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | package Exception::Class::Try::Catch; | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use 5.006; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 1 | our $VERSION = '0.1'; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Exception::Class::Base; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use Exporter 5.57 'import'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use Scalar::Util; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use Try::Catch qw(try); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 1 | $Carp::Internal{+__PACKAGE__} = 1; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 1 | our @EXPORT_OK = qw(try catch); | |||||||||||||||||||||||||||
| 20 | 1 | our @EXPORT = @EXPORT_OK; | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | sub catch (&;@) { | ||||||||||||||||||||||||||||
| 23 | 17 | ▶ | my $block = $_[0]; | ||||||||||||||||||||||||||
|
Subroutine
catch: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 24 | $_[0] = sub { | ||||||||||||||||||||||||||||
| 25 | 15 | ▶ | my $error = $_[0]; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||
| 26 | 15 | ▶ | if (Scalar::Util::blessed($error) and not $error->isa('Exception::Class::Base')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
builtin::blessed($error) and not $error->isa("Exception::Class::Base")
MC/DC100%2/2
builtin::blessed($error) and not $error->isa("Exception::Class::Base")
builtin::blessed($error)
not $error->isa("Exception::Class::Base")
Truth table100%3/3
A and not(B)
A= builtin::blessed($error)B= not $error->isa("Exception::Class::Base")
| |||||||||||||||||||||||||||||
| 27 | 3 | ▶ | $error = $error->as_string() if $error->can('as_string'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | 3 | $error = "$error"; | |||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | 15 | ▶ | if (not Scalar::Util::blessed($error)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | 8 | $_[0] = $_ = Exception::Class::Base->new($error); | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | 15 | goto &$block; | |||||||||||||||||||||||||||
| 34 | 17 | }; | |||||||||||||||||||||||||||
| 35 | 17 | goto &Try::Catch::catch; | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 1 | 1; | |||||||||||||||||||||||||||
| 39 | __END__ | ||||||||||||||||||||||||||||