1 package Moose::Error::Default;
10 my ( $self, @args ) = @_;
11 $self->create_error_confess( @args );
14 sub create_error_croak {
15 my ( $self, @args ) = @_;
16 $self->_create_error_carpmess( @args );
19 sub create_error_confess {
20 my ( $self, @args ) = @_;
21 $self->_create_error_carpmess( @args, longmess => 1 );
24 sub _create_error_carpmess {
25 my ( $self, %args ) = @_;
27 my $carp_level = 3 + ( $args{depth} || 1 );
28 local $Carp::MaxArgNums = 20; # default is 8, usually we use named args which gets messier though
30 my @args = exists $args{message} ? $args{message} : ();
32 if ( $args{longmess} || $Carp::Verbose ) {
33 local $Carp::CarpLevel = ( $Carp::CarpLevel || 0 ) + $carp_level;
34 return Carp::longmess(@args);
36 return Carp::ret_summary($carp_level, @args);
48 Moose::Error::Default - L<Carp> based error generation for Moose.
52 This class implements L<Carp> based error generation.
54 The default behavior is like L<Moose::Error::Confess>.
62 Create a new error. Delegates to C<create_error_confess>.
64 =item create_error_confess @args
66 =item create_error_croak @args
68 Creates a new errors string of the specified style.