1 package Moose::Error::Default;
7 $VERSION = eval $VERSION;
8 our $AUTHORITY = 'cpan:STEVAN';
12 use base 'Class::MOP::Object';
16 my ( $self, @args ) = @_;
17 $self->create_error_confess( @args );
20 sub create_error_croak {
21 my ( $self, @args ) = @_;
22 $self->_create_error_carpmess( @args );
25 sub create_error_confess {
26 my ( $self, @args ) = @_;
27 $self->_create_error_carpmess( @args, longmess => 1 );
30 sub _create_error_carpmess {
31 my ( $self, %args ) = @_;
33 my $carp_level = 3 + ( $args{depth} || 1 );
34 local $Carp::MaxArgNums = 20; # default is 8, usually we use named args which gets messier though
36 my @args = exists $args{message} ? $args{message} : ();
38 if ( $args{longmess} || $Carp::Verbose ) {
39 local $Carp::CarpLevel = ( $Carp::CarpLevel || 0 ) + $carp_level;
40 return Carp::longmess(@args);
42 return Carp::ret_summary($carp_level, @args);
54 Moose::Error::Default - L<Carp> based error generation for Moose.
58 This class implements L<Carp> based error generation.
60 The default behavior is like L<Moose::Error::Confess>.
68 Create a new error. Delegates to C<create_error_confess>.
70 =item create_error_confess @args
72 =item create_error_croak @args
74 Creates a new errors string of the specified style.