From: Jesse Luehrs Date: Mon, 25 Apr 2011 23:37:06 +0000 (-0500) Subject: we don't need an actual inlined version of this X-Git-Tag: 2.0100~25 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=72c4fdf158c34915aa7c78d07f6ab1fbfd3529c3;p=gitmo%2FMoose.git we don't need an actual inlined version of this --- diff --git a/lib/Moose/Error/Confess.pm b/lib/Moose/Error/Confess.pm index 358be9a..74622b3 100644 --- a/lib/Moose/Error/Confess.pm +++ b/lib/Moose/Error/Confess.pm @@ -11,9 +11,13 @@ sub new { } sub _inline_new { - my ( $self, @args ) = @_; + my ( $self, %args ) = @_; - return $self->_inline_create_error_carpmess(@args, longmess => 1); + my $depth = ($args{depth} || 0) - 1; + return $self . '->new(' + . 'message => ' . $args{message} . ', ' + . 'depth => ' . $depth . ', ' + . ')'; } 1; diff --git a/lib/Moose/Error/Croak.pm b/lib/Moose/Error/Croak.pm index 9917b96..b6a9a9f 100644 --- a/lib/Moose/Error/Croak.pm +++ b/lib/Moose/Error/Croak.pm @@ -11,9 +11,13 @@ sub new { } sub _inline_new { - my ( $self, @args ) = @_; + my ( $self, %args ) = @_; - return $self->_inline_create_error_carpmess(@args); + my $depth = ($args{depth} || 0) - 1; + return $self . '->new(' + . 'message => ' . $args{message} . ', ' + . 'depth => ' . $depth . ', ' + . ')'; } 1; diff --git a/lib/Moose/Error/Default.pm b/lib/Moose/Error/Default.pm index d3673f0..7944cd8 100644 --- a/lib/Moose/Error/Default.pm +++ b/lib/Moose/Error/Default.pm @@ -21,13 +21,13 @@ sub new { } sub _inline_new { - my ( $self, @args ) = @_; + my ( $self, %args ) = @_; - return '(do { ' - . '(defined $ENV{MOOSE_ERROR_STYLE} && $ENV{MOOSE_ERROR_STYLE} eq "croak"' - . ' ? ' . $self->_inline_create_error_carpmess(@args) - . ' : ' . $self->_inline_create_error_carpmess(@args, longmess => 1) - . ')})'; + my $depth = ($args{depth} || 0) - 1; + return $self . '->new(' + . 'message => ' . $args{message} . ', ' + . 'depth => ' . $depth . ', ' + . ')'; } sub create_error_croak { @@ -43,7 +43,7 @@ sub create_error_confess { sub _create_error_carpmess { my ( $self, %args ) = @_; - my $carp_level = 3 + ( $args{depth} || 1 ); + my $carp_level = 4 + ( $args{depth} || 0 ); local $Carp::MaxArgNums = 20; # default is 8, usually we use named args which gets messier though my @args = exists $args{message} ? $args{message} : (); @@ -56,31 +56,6 @@ sub _create_error_carpmess { } } -sub _inline_create_error_carpmess { - my ( $self, %args ) = @_; - - my $carp_level = $args{depth} || 0; - - my $create_message = 'Carp::longmess(' . $args{message} . ')'; - - if (!$args{longmess}) { - $create_message = - '($Carp::Verbose ' - . '? ' . $create_message . ' ' - . ': Carp::ret_summary(' - . $carp_level . ', ' . $args{message} - . '))'; - } - - return - '(do { ' - . 'local $Carp::MaxArgNums = 20; ' - . 'local $Carp::CarpLevel = ($Carp::CarpLevel || 0) + ' - . $carp_level . '; ' - . $create_message - . '})'; -} - 1; # ABSTRACT: L based error generation for Moose.