1 package Moose::Error::Default;
7 $VERSION = eval $VERSION;
8 our $AUTHORITY = 'cpan:STEVAN';
14 my ( $self, @args ) = @_;
15 $self->create_error_confess( @args );
18 sub create_error_croak {
19 my ( $self, @args ) = @_;
20 $self->_create_error_carpmess( @args );
23 sub create_error_confess {
24 my ( $self, @args ) = @_;
25 $self->_create_error_carpmess( @args, longmess => 1 );
28 sub _create_error_carpmess {
29 my ( $self, %args ) = @_;
31 my $carp_level = 3 + ( $args{depth} || 1 );
32 local $Carp::MaxArgNums = 20; # default is 8, usually we use named args which gets messier though
34 my @args = exists $args{message} ? $args{message} : ();
36 if ( $args{longmess} || $Carp::Verbose ) {
37 local $Carp::CarpLevel = ( $Carp::CarpLevel || 0 ) + $carp_level;
38 return Carp::longmess(@args);
40 return Carp::ret_summary($carp_level, @args);
52 Moose::Error::Default - L<Carp> based error generation for Moose.
56 This class implements L<Carp> based error generation.
58 The default behavior is like L<Moose::Error::Confess>.
66 Create a new error. Delegates to C<create_error_confess>.
68 =item create_error_confess @args
70 =item create_error_croak @args
72 Creates a new errors string of the specified style.