X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FError%2FDefault.pm;h=c07c626b26fdea3e8da89101ed79ac3ad2f3d7bc;hb=d5f6cadef8d83deaf7dd95302908cd4f61aeab8a;hp=ea5717de3fc6cedf41064e0cc0ba6d94d5bcc1b0;hpb=d344c3feeb1c99183a249e26ddfb0e790101f7b2;p=gitmo%2FMoose.git diff --git a/lib/Moose/Error/Default.pm b/lib/Moose/Error/Default.pm index ea5717d..c07c626 100644 --- a/lib/Moose/Error/Default.pm +++ b/lib/Moose/Error/Default.pm @@ -3,16 +3,21 @@ package Moose::Error::Default; use strict; use warnings; -our $VERSION = '0.68'; -$VERSION = eval $VERSION; -our $AUTHORITY = 'cpan:STEVAN'; - use Carp::Heavy; +use Class::MOP::MiniTrait; + +use base 'Class::MOP::Object'; +Class::MOP::MiniTrait::apply(__PACKAGE__, 'Moose::Meta::Object::Trait'); sub new { my ( $self, @args ) = @_; - $self->create_error_confess( @args ); + if (defined $ENV{MOOSE_ERROR_STYLE} && $ENV{MOOSE_ERROR_STYLE} eq 'croak') { + $self->create_error_croak( @args ); + } + else { + $self->create_error_confess( @args ); + } } sub create_error_croak { @@ -43,31 +48,34 @@ sub _create_error_carpmess { __PACKAGE__ +# ABSTRACT: L based error generation for Moose. + __END__ =pod -=head1 NAME - -Moose::Error::Default - L based error generation for Moose. - =head1 DESCRIPTION This class implements L based error generation. -The default behavior is like L. +The default behavior is like L. To override this to +default to L's behaviour on a system wide basis, set the +MOOSE_ERROR_STYLE environment variable to C. The use of this +environment variable is considered experimental, and may change in a future +release. =head1 METHODS =over 4 -=item new @args +=item B<< Moose::Error::Default->new(@args) >> -Create a new error. Delegates to C. +Create a new error. Delegates to C or +C. -=item create_error_confess @args +=item B<< $error->create_error_confess(@args) >> -=item create_error_croak @args +=item B<< $error->create_error_croak(@args) >> Creates a new errors string of the specified style.