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