| 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.0'; | |||||||||||||||||||
| 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
| |||||||||||||||||||||
| 14 | 17 | ▶ | $fields{message} = Carp::shortmess( $fields{message} // $class ); | ||||||||||||||||||
|
Condition33%1/3
$fields{"message"} // $class
MC/DC0%0/2
$fields{"message"} // $class
$fields{"message"}
$class
Truth table33%1/3
A // B
A= $fields{"message"}B= $class
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 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 | ||||||||||||||||||||