| 1 | package Perl::Critic::Exception::AggregateConfiguration; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 40 | ▶ | use 5.010001; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 40 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | 40 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | |||||||||||||||
| 7 | 40 | ▶ | use Carp qw{ confess }; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 8 | 40 | ▶ | use Readonly; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 9 | |||||||||||||||
| 10 | 40 | ▶ | use Perl::Critic::Utils qw{ :characters }; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 11 | |||||||||||||||
| 12 | 40 | our $VERSION = '1.156'; | |||||||||||||
| 13 | |||||||||||||||
| 14 | #----------------------------------------------------------------------------- | ||||||||||||||
| 15 | |||||||||||||||
| 16 | 40 | ▶ | use Exception::Class ( | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 17 | 40 | 'Perl::Critic::Exception::AggregateConfiguration' => { | |||||||||||||
| 18 | isa => 'Perl::Critic::Exception', | ||||||||||||||
| 19 | description => 'A collected set of configuration exceptions.', | ||||||||||||||
| 20 | fields => [ qw{ exceptions } ], | ||||||||||||||
| 21 | alias => 'throw_aggregate', | ||||||||||||||
| 22 | }, | ||||||||||||||
| 23 | 40 | ); | |||||||||||||
| 24 | |||||||||||||||
| 25 | #----------------------------------------------------------------------------- | ||||||||||||||
| 26 | |||||||||||||||
| 27 | 40 | Readonly::Array our @EXPORT_OK => qw< throw_aggregate >; | |||||||||||||
| 28 | |||||||||||||||
| 29 | #----------------------------------------------------------------------------- | ||||||||||||||
| 30 | |||||||||||||||
| 31 | 38729 | ▶ | sub new { | ||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||
| 32 | 38729 | my ($class, %options) = @_; | |||||||||||||
| 33 | |||||||||||||||
| 34 | 38729 | my $exceptions = $options{exceptions}; | |||||||||||||
| 35 | 38729 | ▶ | if (not $exceptions) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 36 | 38729 | $options{exceptions} = []; | |||||||||||||
| 37 | } | ||||||||||||||
| 38 | |||||||||||||||
| 39 | 38729 | return $class->SUPER::new(%options); | |||||||||||||
| 40 | } | ||||||||||||||
| 41 | |||||||||||||||
| 42 | #----------------------------------------------------------------------------- | ||||||||||||||
| 43 | |||||||||||||||
| 44 | 164 | ▶ | sub add_exception { | ||||||||||||
|
Subroutine
add_exception: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 45 | 164 | my ( $self, $exception ) = @_; | |||||||||||||
| 46 | |||||||||||||||
| 47 | 164 | push @{ $self->exceptions() }, $exception; | |||||||||||||
| 48 | |||||||||||||||
| 49 | 164 | return; | |||||||||||||
| 50 | } | ||||||||||||||
| 51 | |||||||||||||||
| 52 | #----------------------------------------------------------------------------- | ||||||||||||||
| 53 | |||||||||||||||
| 54 | 1 | ▶ | sub add_exceptions_from { | ||||||||||||
|
Subroutine
add_exceptions_from: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 55 | 1 | my ( $self, $aggregate ) = @_; | |||||||||||||
| 56 | |||||||||||||||
| 57 | 1 | push @{ $self->exceptions() }, @{ $aggregate->exceptions() }; | |||||||||||||
| 58 | |||||||||||||||
| 59 | 1 | return; | |||||||||||||
| 60 | } | ||||||||||||||
| 61 | |||||||||||||||
| 62 | #----------------------------------------------------------------------------- | ||||||||||||||
| 63 | |||||||||||||||
| 64 | 21744 | ▶ | sub add_exception_or_rethrow { | ||||||||||||
|
Subroutine
add_exception_or_rethrow: called CC=5 SCAR=16.4
Pod
documented
| |||||||||||||||
| 65 | 21744 | my ( $self, $eval_error ) = @_; | |||||||||||||
| 66 | |||||||||||||||
| 67 | 21744 | ▶ | return if not $eval_error; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 68 | 2 | ▶ | confess $eval_error if not ref $eval_error; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 69 | |||||||||||||||
| 70 | 2 | ▶ | if ( $eval_error->isa('Perl::Critic::Exception::Configuration') ) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 71 | 1 | $self->add_exception($eval_error); | |||||||||||||
| 72 | } | ||||||||||||||
| 73 | elsif ( | ||||||||||||||
| 74 | $eval_error->isa('Perl::Critic::Exception::AggregateConfiguration') | ||||||||||||||
| 75 | ) { | ||||||||||||||
| 76 | 1 | $self->add_exceptions_from($eval_error); | |||||||||||||
| 77 | } | ||||||||||||||
| 78 | else { | ||||||||||||||
| 79 | 0 | die $eval_error; ## no critic (RequireCarping) | |||||||||||||
| 80 | } | ||||||||||||||
| 81 | |||||||||||||||
| 82 | 2 | return; | |||||||||||||
| 83 | } | ||||||||||||||
| 84 | |||||||||||||||
| 85 | #----------------------------------------------------------------------------- | ||||||||||||||
| 86 | |||||||||||||||
| 87 | 39336 | ▶ | sub has_exceptions { | ||||||||||||
|
Subroutine
has_exceptions: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||
| 88 | 39336 | my ( $self ) = @_; | |||||||||||||
| 89 | |||||||||||||||
| 90 | 39336 | ▶ | return @{ $self->exceptions() } ? 1 : 0; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 91 | } | ||||||||||||||
| 92 | |||||||||||||||
| 93 | #----------------------------------------------------------------------------- | ||||||||||||||
| 94 | |||||||||||||||
| 95 | 40 | Readonly::Scalar my $MESSAGE_PREFIX => $EMPTY; | |||||||||||||
| 96 | 40 | Readonly::Scalar my $MESSAGE_SUFFIX => "\n"; | |||||||||||||
| 97 | 40 | Readonly::Scalar my $MESSAGE_SEPARATOR => $MESSAGE_SUFFIX . $MESSAGE_PREFIX; | |||||||||||||
| 98 | |||||||||||||||
| 99 | 150 | ▶ | sub full_message { | ||||||||||||
|
Subroutine
full_message: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 100 | 150 | my ( $self ) = @_; | |||||||||||||
| 101 | |||||||||||||||
| 102 | 150 | my $message = $MESSAGE_PREFIX; | |||||||||||||
| 103 | 150 | $message .= join $MESSAGE_SEPARATOR, @{ $self->exceptions() }; | |||||||||||||
| 104 | 150 | $message .= $MESSAGE_SUFFIX; | |||||||||||||
| 105 | |||||||||||||||
| 106 | 150 | return $message; | |||||||||||||
| 107 | } | ||||||||||||||
| 108 | |||||||||||||||
| 109 | 40 | 1; | |||||||||||||
| 110 | |||||||||||||||
| 111 | #----------------------------------------------------------------------------- | ||||||||||||||
| 112 | |||||||||||||||
| 113 | __END__ | ||||||||||||||