lib/Catalyst/Exception/Basic.pm

filter: Statementstmt 96.4% 27 / 28 Branchbran 50.0% 3 / 6 Conditioncond 33.3% 2 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 87.5% 7 / 8 Podpod 100% 3 / 3 totaltotal 78.1% 43 / 55 CC 6 SCAR 12.8
CC
6
Cov
80%
__ANON__
6.0
__ANON__
5.8
BEGIN
1.0
CRAP 3.6
« lib/Catalyst/ActionRole/Scheme.pm ↑ Summary lib/Catalyst/DispatchType/Index.pm »
1 package Catalyst::Exception::Basic;
2  
3 180 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 180 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 180 ▶use namespace::clean -except => 'meta';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 180 with 'Catalyst::Exception::Interface';
8  
9 has message => (
10 is => 'ro',
11 isa => 'Str',
12 0 ▶ default => sub { $! || '' },
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
$! or "" 0 0 0
13 180 );
14  
15 126 ▶sub as_string {
Subroutine as_string: called CC=1 SCAR=0.0
Pod documented
16 126 my ($self) = @_;
17 126 return $self->message;
18 }
19  
20 363 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=5 SCAR=17.5
21 363 my ($next, $class, @args) = @_;
22 363 ▶ if (@args == 1 && !ref $args[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args == 1 and not ref $args[0]) 8 355 363
Condition66%2/3
@args == 1 and not ref $args[0]
!ll&&!rl&&r
35508
MC/DC50%1/2
@args == 1 and not ref $args[0]
@args == 1 not ref $args[0]
Truth table66%2/3
A and not(B)
A= @args == 1B= not ref $args[0]
ABresult
0X0
100
111
23 8 @args = (message => $args[0]);
24 }
25  
26 363 my $args = $class->$next(@args);
27 $args->{message} ||= $args->{error}
28 363 ▶ if exists $args->{error};
Branch: 1 branch
BranchTrueFalseTotal
if exists $args->{"error"} 0 363 363
Condition0%0/3
$args->{"message"} ||= $args->{"error"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$args->{"message"} ||= $args->{"error"}
$args->{"message"} $args->{"error"}
Truth table0%0/3
A ||= B
A= $args->{"message"}B= $args->{"error"}
ABresult
1X1
011
000
29  
30 363 return $args;
31 180 };
32  
33 35 ▶sub throw {
Subroutine throw: called CC=1 SCAR=0.0
Pod documented
34 35 my $class = shift;
35 35 my $error = $class->new(@_);
36 35 local $Carp::CarpLevel = 1;
37 35 croak $error;
38 }
39  
40 68 ▶sub rethrow {
Subroutine rethrow: called CC=1 SCAR=0.0
Pod documented
41 68 my ($self) = @_;
42 68 croak $self;
43 }
44  
45 180 1;
46  
47 =head1 NAME
48  
49 Catalyst::Exception::Basic - Basic Catalyst Exception Role
50  
51 =head1 SYNOPSIS
52  
53 package My::Exception;
54 use Moose;
55 use namespace::clean -except => 'meta';
56  
57 with 'Catalyst::Exception::Basic';
58  
59 # Elsewhere..
60 My::Exception->throw( qq/Fatal exception/ );
61  
62 See also L<Catalyst> and L<Catalyst::Exception>.
63  
64 =head1 DESCRIPTION
65  
66 This is the basic Catalyst Exception role which implements all of
67 L<Catalyst::Exception::Interface>.
68  
69 =head1 ATTRIBUTES
70  
71 =head2 message
72  
73 Holds the exception message.
74  
75 =head1 METHODS
76  
77 =head2 as_string
78  
79 Stringifies the exception's message attribute.
80 Called when the object is stringified by overloading.
81  
82 =head2 throw( $message )
83  
84 =head2 throw( message => $message )
85  
86 =head2 throw( error => $error )
87  
88 Throws a fatal exception.
89  
90 =head2 rethrow( $exception )
91  
92 Rethrows a caught exception.
93  
94 =head2 meta
95  
96 Provided by Moose
97  
98 =head1 AUTHORS
99  
100 Catalyst Contributors, see Catalyst.pm
101  
102 =head1 COPYRIGHT
103  
104 This library is free software. You can redistribute it and/or modify
105 it under the same terms as Perl itself.
106  
107 =cut
« lib/Catalyst/ActionRole/Scheme.pm ↑ Summary lib/Catalyst/DispatchType/Index.pm »