summaryrefslogtreecommitdiff
path: root/lib/Moose/Exception/OverrideConflictInComposition.pm
blob: 44bfd78614c8a644e41324376d3af01a68fc3023 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package Moose::Exception::OverrideConflictInComposition;
our $VERSION = '2.1405';

use Moose;
extends 'Moose::Exception';
with 'Moose::Exception::Role::Role';

has 'role_being_applied_name' => (
    is       => 'ro',
    isa      => 'Str',
    required => 1
);

has 'method_name' => (
    is       => 'ro',
    isa      => 'Str',
    required => 1
);

has 'two_overrides_found' => (
    is       => 'ro',
    isa      => 'Bool',
    required => 1,
    default  => 0
);

sub _build_message {
    my $self = shift;

    if( $self->two_overrides_found ) {
        return "Role '" . $self->role_being_applied_name . "' has encountered an 'override' method conflict " .
               "during composition (Two 'override' methods of the same name encountered). " .
               "This is a fatal error.";
    }
    else {
        return "Role '".$self->role_being_applied_name."' has encountered an 'override' method conflict ".
               "during composition (A local method of the same name as been found). ".
               "This is a fatal error.";
    }
}

1;