lib/At/Error.pm

filter: Statementstmt 96.4% 55 / 57 Branchbran 78.5% 11 / 14 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 93.7% 15 / 16 Podpod 100% 2 / 2 totaltotal 89.3% 84 / 94 CC 12 SCAR 8.9
CC
12
Cov
91%
import
5.2
__ANON__
3.6
throw
2.0
CRAP 2.4
« lib/At/Protocol/DID.pm ↑ Summary
1 9 ▶use v5.42;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 9 ▶use feature 'class';
Subroutine BEGIN: called CC=1 SCAR=0.0
3 9 ▶no warnings 'experimental::class';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 9 class At::Error v1.8.0 {
5 9 ▶ use Carp qw[];
Subroutine BEGIN: called CC=1 SCAR=0.0
6 use overload
7 1 ▶ bool => sub {0},
Subroutine BEGIN: called CC=1 SCAR=0.1
Subroutine __ANON__: called CC=1 SCAR=0.0
8 0 ▶ '""' => sub ( $s, $u, $q ) { $s->message };
Subroutine __ANON__: not called CC=1 SCAR=0.2
9 9 field $message : param : reader;
10 9 field $description : param : reader //= ();
11 9 field $fatal : param : reader //= 0;
12 9 field @stack;
13 775 ▶ ADJUST {
Subroutine __ANON__: called CC=2 SCAR=6.9
14 775 my $i = 0;
15 775 ▶ while ( my $info = $self->_caller_info( ++$i ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $info = $self->_caller_info(++$i)) 14350 775 15125
16 14350 push @stack, $info;
17 }
18 }
19  
20 15125 ▶ method _caller_info($i) {
Subroutine _caller_info: called CC=2 SCAR=6.9
21 15125 my ( $package, $filename, $line, $subroutine ) = caller($i);
22 15125 ▶ return unless $package;
Branch: 1 branch
BranchTrueFalseTotal
unless $package 775 14350 15125
23 14350 return { package => $package, file => $filename, line => $line, sub_name => $subroutine };
24 }
25  
26 775 ▶ method throw() {
Subroutine throw: called CC=2 SCAR=7.0
Pod documented
27 775 my ( undef, $file, $line ) = caller();
28 my $msg = join "\n\t", sprintf( qq[%s at %s line %d\n], $message, $file, $line ),
29 775 map { sprintf q[%s called at %s line %d], $_->{sub_name}, $_->{file}, $_->{line} } @stack;
30 775 ▶ $fatal ? die "$msg\n" : warn "$msg\n";
Branch: 1 branch
BranchTrueFalseTotal
$fatal ? : 775 0 775
31 }
32  
33 # Compatibility with old At::Error
34 29 ▶ sub import {
Subroutine import: called CC=5 SCAR=16.4
35 29 my $class = shift;
36 29 my $from = caller;
37 9 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
38 29 ▶ my @syms = @_ ? @_ : qw[register throw];
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 23 6 29
39 29 for my $sym (@syms) {
40 58 ▶ if ( $sym eq 'register' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($sym eq 'register') { } 29 29 58
elsif ($sym eq 'throw') { } 29 0 29
41 29 *{ $from . '::register' } = \&register;
42 }
43 elsif ( $sym eq 'throw' ) {
44 29 ▶ *{ $from . '::throw' } = sub {
Subroutine __ANON__: called CC=3 SCAR=12.7
45 775 my $err = shift;
46 775 ▶ if ( builtin::blessed($err) && $err->isa('At::Error') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($err) and $err->isa('At::Error')) { } 775 0 775
Condition33%1/3
builtin::blessed($err) and $err->isa("At::Error")
!ll&&!rl&&r
00775
MC/DC0%0/2
builtin::blessed($err) and $err->isa("At::Error")
builtin::blessed($err) $err->isa("At::Error")
Truth table33%1/3
A and B
A= builtin::blessed($err)B= $err->isa("At::Error")
ABresult
0X0
100
111
47 775 $err->throw;
48 }
49 else {
50 0 die $err;
51 }
52 29 };
53 }
54 }
55 }
56  
57 42 ▶ sub register( $name, $is_fatal = 0 ) {
Subroutine register: called CC=2 SCAR=6.9
Pod documented
58 42 my ($from) = caller;
59 9 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
60 42 ▶ *{ $from . '::' . $name } = sub ( $msg, $desc = '' ) {
Subroutine __ANON__: called CC=2 SCAR=6.9
61 775 At::Error->new( message => $msg, description => $desc, fatal => $is_fatal );
62 42 };
63 }
64 9 } 1;
65 __END__
« lib/At/Protocol/DID.pm ↑ Summary