| 1 | package Moose::Exception::AttributeIsRequired; | ||||||||||||||||||||||||||||
| 2 | 14 | our $VERSION = '2.4001'; | |||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 14 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 14 | extends 'Moose::Exception'; | |||||||||||||||||||||||||||
| 6 | 14 | with 'Moose::Exception::Role::Class'; | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 14 | has 'attribute_name' => ( | |||||||||||||||||||||||||||
| 9 | is => 'ro', | ||||||||||||||||||||||||||||
| 10 | isa => 'Str', | ||||||||||||||||||||||||||||
| 11 | required => 1, | ||||||||||||||||||||||||||||
| 12 | documentation => "This attribute can be used for fetching attribute instance:\n". | ||||||||||||||||||||||||||||
| 13 | " my \$class = Moose::Util::find_meta( \$exception->class_name );\n". | ||||||||||||||||||||||||||||
| 14 | " my \$attribute = \$class->get_attribute( \$exception->attribute_name );\n", | ||||||||||||||||||||||||||||
| 15 | ); | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 14 | has 'attribute_init_arg' => ( | |||||||||||||||||||||||||||
| 18 | is => 'ro', | ||||||||||||||||||||||||||||
| 19 | isa => 'Str', | ||||||||||||||||||||||||||||
| 20 | ); | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 14 | has 'params' => ( | |||||||||||||||||||||||||||
| 23 | is => 'ro', | ||||||||||||||||||||||||||||
| 24 | isa => 'HashRef', | ||||||||||||||||||||||||||||
| 25 | predicate => 'has_params', | ||||||||||||||||||||||||||||
| 26 | ); | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 60 | ▶ | sub _build_message { | ||||||||||||||||||||||||||
|
Subroutine
_build_message: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 29 | 60 | my $self = shift; | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 60 | my $name = $self->attribute_name; | |||||||||||||||||||||||||||
| 32 | 60 | my $msg = "Attribute ($name)"; | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 60 | my $init_arg = $self->attribute_init_arg; | |||||||||||||||||||||||||||
| 35 | 60 | ▶ | if ( defined $init_arg && $name ne $init_arg ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $init_arg and $name ne $init_arg
MC/DC50%1/2
defined $init_arg and $name ne $init_arg
defined $init_arg
$name ne $init_arg
Truth table66%2/3
A and B
A= defined $init_argB= $name ne $init_arg
| |||||||||||||||||||||||||||||
| 36 | 1 | $msg .= ", passed as ($init_arg),"; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 60 | $msg .= ' is required'; | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 60 | return $msg; | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 14 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 45 | 14 | 1; | |||||||||||||||||||||||||||