7 'Test::Output' => '0.01',
11 package My::Exception;
21 has [qw( line file package )] => (
35 use parent qw( Moose::Error::Default );
38 my ( $self, @args ) = @_;
40 $self->create_error_exception(@args)->throw;
43 sub create_error_exception {
44 my ( $self, %params ) = @_;
46 my $exception = My::Exception->new(
47 error => $params{message},
48 line => $params{line},
49 file => $params{file},
50 package => $params{pack},
62 __PACKAGE__->meta->error_class("My::Error");
70 sub { __PACKAGE__->meta->make_immutable },
72 'no warnings when calling make_immutable with a custom error class'
77 package My::ClassMutable;
81 __PACKAGE__->meta->error_class("My::Error");
98 $error, 'My::Exception',
99 'got exception object (immutable class)'
102 $error->error, 'Attribute (test1) is required',
103 'got the right message (immutable class)'
106 $error->package, 'My::Test',
107 'got the right package (immutable class)'
109 is( $error->line, 42, 'got the right line (immutable class)' );
114 package My::TestMutable;
116 My::ClassMutable->new;
120 isa_ok( $error, 'My::Exception', 'got exception object (mutable class)' );
122 $error->error, 'Attribute (test1) is required',
123 'got the right message (mutable class)'