| 1 | package Valiant::Util::Exception::MissingMethod; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | extends 'Valiant::Util::Exception'; | |||||||||
| 5 | |||||||||||
| 6 | 1 | has object => (is=>'ro', required=>1); | |||||||||
| 7 | 1 | has method => (is=>'ro', required=>1); | |||||||||
| 8 | |||||||||||
| 9 | 1 | ▶ | sub _build_message { | ||||||||
|
Subroutine
_build_message: called CC=2 SCAR=8.7
| |||||||||||
| 10 | 1 | my ($self) = @_; | |||||||||
| 11 | 1 | ▶ | if(ref $self->method) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 12 | 0 | my $methods = join ', ', @{$self->method}; | |||||||||
| 13 | 0 | return "Object '@{[ ref $self->object ]}' must provide one of the following methods: $methods"; | |||||||||
| 14 | } else { | ||||||||||
| 15 | 1 | return "Object '@{[ ref $self->object ]}' has no method '@{[ $self->method ]}'."; | |||||||||
| 16 | } | ||||||||||
| 17 | } | ||||||||||
| 18 | |||||||||||
| 19 | 1 | 1; | |||||||||
| 20 | |||||||||||
| 21 | =head1 NAME | ||||||||||
| 22 | |||||||||||
| 23 | Valiant::Util::Exception::MissingMethod - Object is missing method | ||||||||||
| 24 | |||||||||||
| 25 | =head1 SYNOPSIS | ||||||||||
| 26 | |||||||||||
| 27 | die Valiant::Exception::MissingMethod->new(object=>$self, method=>'if'); | ||||||||||
| 28 | |||||||||||
| 29 | =head1 DESCRIPTION | ||||||||||
| 30 | |||||||||||
| 31 | Encapsulates an error when you want to call a method on an object but that object fails | ||||||||||
| 32 | to have that method. | ||||||||||
| 33 | |||||||||||
| 34 | =head1 ATTRIBUTES | ||||||||||
| 35 | |||||||||||
| 36 | =head2 object | ||||||||||
| 37 | |||||||||||
| 38 | =head2 method | ||||||||||
| 39 | |||||||||||
| 40 | The string name of the missing method and a reference to the object that was missing it. If the | ||||||||||
| 41 | method attribute is an arrayref than means 'one of these methods' must be provided. | ||||||||||
| 42 | |||||||||||
| 43 | =head2 message | ||||||||||
| 44 | |||||||||||
| 45 | The actual exception message | ||||||||||
| 46 | |||||||||||
| 47 | =head1 SEE ALSO | ||||||||||
| 48 | |||||||||||
| 49 | L<Valiant> | ||||||||||
| 50 | |||||||||||
| 51 | =head1 AUTHOR | ||||||||||
| 52 | |||||||||||
| 53 | See L<Valiant> | ||||||||||
| 54 | |||||||||||
| 55 | =head1 COPYRIGHT & LICENSE | ||||||||||
| 56 | |||||||||||
| 57 | See L<Valiant> | ||||||||||
| 58 | |||||||||||
| 59 | =cut | ||||||||||