blib/lib/Pandoc/Error.pm

filter: Statementstmt 100% 19 / 19 Branchbran 75.0% 3 / 4 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 7 / 7 Podpod 66.6% 2 / 3 totaltotal 84.2% 32 / 38 SCAR 13.9
CC
4
Cov
88%
new
3.1
throw
2.1
BEGIN
1.0
CRAP 4.0
« blib/lib/Pandoc/Version.pm ↑ Summary Build »
1 package Pandoc::Error;
2 11 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 11 our $VERSION = '0.9.1';
6  
7 11 ▶use overload '""' => 'message', fallback => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 11 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 11 $Carp::CarpInternal{ (__PACKAGE__) }++; # don't include package in stack trace
11  
12 sub new {
13 17 ▶ my ( $class, %fields ) = @_ % 2 ? @_ : ( shift, message => @_ );
Subroutine new: called CC=3 SCAR=11.4
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
@_ % 2 ? : 14 3 17
14 17 ▶ $fields{message} = Carp::shortmess( $fields{message} // $class );
Condition33%1/3
$fields{"message"} // $class
l!l&&r!l&&!r
1700
MC/DC0%0/2
$fields{"message"} // $class
$fields{"message"} $class
Truth table33%1/3
A // B
A= $fields{"message"}B= $class
ABresult
1X1
011
000
15 17 bless \%fields, $class;
16 }
17  
18 sub throw {
19 17 ▶ die ref $_[0] ? $_[0] : shift->new(@_);
Subroutine throw: called CC=2 SCAR=7.6
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 17 17
20 }
21  
22 sub message {
23 9 ▶ $_[0]->{message};
Subroutine message: called CC=1 SCAR=0.0
Pod documented
24 }
25  
26 11 1;
27  
28 =head1 NAME
29  
30 Pandoc::Error - Pandoc document processing error
31  
32 =head1 SYNOPSIS
33  
34 use Try::Tiny;
35  
36 try {
37 ...
38 } catch {
39 if ( blessed $_ && $_->isa('Pandoc::Error') ) {
40 ...
41 }
42 };
43  
44 =head1 METHODS
45  
46 =head2 throw( [ %fields ] )
47  
48 Throw an existing error or create and throw a new error. Setting field
49 C<message> is recommended. The message is enriched with error location. A
50 stack trace can be added with L<$Carp::Verbose|Carp/$Carp::Verbose> or
51 L<Carp::Always>.
52  
53 =head2 message
54  
55 The error message. Also returned on stringification.
56  
57 =head1 SEE ALSO
58  
59 This class does not inherit from L<Throwable>, L<Exception::Class> or
60 L<Class::Exception> but may do so in a future version.
61  
62 =cut
« blib/lib/Pandoc/Version.pm ↑ Summary Build »