Skip to content

Commit

Permalink
rearranged how the @CARP_NOT works to make it easier to add more pack…
Browse files Browse the repository at this point in the history
…ages
  • Loading branch information
barefootcoder committed Apr 7, 2011
1 parent a58cebe commit d663b9c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/Method/Signatures.pm
Original file line number Diff line number Diff line change
Expand Up @@ -793,15 +793,18 @@ sub _type_error
{
my ($msg) = @_;

local @CARP_NOT = ( __PACKAGE__ );
my $skip = qr/^${\(join('|', @CARP_NOT))}/;

my $caller;
my $pkg = __PACKAGE__;
my $level = 0;
do {
$caller = (caller(++$level))[3];
} while $caller =~ /^$pkg/;
} while $caller =~ /$skip/;

($pkg = $caller) =~ s/::(\w+)?$//;
local @CARP_NOT = ( $pkg );
# we don't need __PACKAGE__ in @CARP_NOT, but we do need the package of the sub with the error
(my $pkg = $caller) =~ s/::(\w+)?$//;
$CARP_NOT[0] = $pkg;

require Carp;
Carp::croak "In call to $caller : $msg";
Expand Down

0 comments on commit d663b9c

Please sign in to comment.