1 package Moose::Error::Default;
8 use Moose::Error::Util;
10 use base 'Class::MOP::Object';
13 my ( $self, @args ) = @_;
14 # can't use Moose::Error::Util::create_error here because that would break
15 # inheritance. we don't care about that for the inlined version, because
16 # the inlined versions are explicitly not inherited.
17 if (defined $ENV{MOOSE_ERROR_STYLE} && $ENV{MOOSE_ERROR_STYLE} eq 'croak') {
18 $self->create_error_croak( @args );
21 $self->create_error_confess( @args );
26 my ( $self, %args ) = @_;
28 my $depth = ($args{depth} || 0) - 1;
29 return 'Moose::Error::Util::create_error('
30 . 'message => ' . $args{message} . ', '
31 . 'depth => ' . $depth . ', '
35 sub create_error_croak {
36 my ( $self, @args ) = @_;
37 return Moose::Error::Util::create_error_croak(@args);
40 sub create_error_confess {
41 my ( $self, @args ) = @_;
42 return Moose::Error::Util::create_error_confess(@args);
47 # ABSTRACT: L<Carp> based error generation for Moose.
55 This class implements L<Carp> based error generation.
57 The default behavior is like L<Moose::Error::Confess>. To override this to
58 default to L<Moose::Error::Croak>'s behaviour on a system wide basis, set the
59 MOOSE_ERROR_STYLE environment variable to C<croak>. The use of this
60 environment variable is considered experimental, and may change in a future
67 =item B<< Moose::Error::Default->new(@args) >>
69 Create a new error. Delegates to C<create_error_confess> or
70 C<create_error_croak>.
72 =item B<< $error->create_error_confess(@args) >>
74 =item B<< $error->create_error_croak(@args) >>
76 Creates a new errors string of the specified style.