| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 39 | 29 | for my $sym (@syms) { | |||||||||||||||||||||||||||
| 40 | 58 | ▶ | if ( $sym eq 'register' ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 41 | 29 | *{ $from . '::register' } = \®ister; | |||||||||||||||||||||||||||
| 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
Condition33%1/3
builtin::blessed($err) and $err->isa("At::Error")
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")
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||