# Carp::Heavy uses some variables in common with Carp.
package Carp;
+=head1 NAME
+
+Carp heavy machinery - no user serviceable parts inside
+
+=cut
+
# use strict; # not yet
# On one line so MakeMaker will see it.
my $sub_name = Carp::get_subname(\%call_info);
if ($call_info{has_args}) {
- # Reuse the @args array to avoid warnings. :-)
- local @args = map {Carp::format_arg($_)} @args;
+ my @args = map {Carp::format_arg($_)} @args;
if ($MaxArgNums and @args > $MaxArgNums) { # More than we want to show?
$#args = $MaxArgNums;
push @args, '...';
$arg = 'undef';
}
elsif (ref($arg)) {
- $arg .= ''; # Make it a string;
+ $arg = defined($overload::VERSION) ? overload::StrVal($arg) : "$arg";
}
$arg =~ s/'/\\'/g;
$arg = str_len_trim($arg, $MaxLenArg);
# The following handling of "control chars" is direct from
# the original code - I think it is broken on Unicode though.
# Suggestions?
- $arg =~ s/([[:cntrl:]]|[[^:ascii:]])/sprintf("\\x{%x}",ord($1))/eg;
+ $arg =~ s/([[:cntrl:]]|[[:^ascii:]])/sprintf("\\x{%x}",ord($1))/eg;
return $arg;
}
sub longmess_heavy {
- return @_ if ref($_[0]); # WHAT IS THIS FOR???
+ return @_ if ref($_[0]); # don't break references as exceptions
my $i = long_error_loc();
return ret_backtrace($i, @_);
}
$tid_msg = " thread $tid" if $tid;
}
- if ($err =~ /\n$/) {
+ { if ($err =~ /\n$/) { # extra block to localise $1 etc
$mess = $err;
}
else {
my %i = caller_info($i);
$mess = "$err at $i{file} line $i{line}$tid_msg\n";
- }
+ }}
while (my %i = caller_info(++$i)) {
$mess .= "\t$i{sub_name} called at $i{file} line $i{line}$tid_msg\n";
}
- return $mess || $err;
+ return $mess;
}
sub ret_summary {
sub shortmess_heavy {
return longmess_heavy(@_) if $Verbose;
- return @_ if ref($_[0]); # WHAT IS THIS FOR???
+ return @_ if ref($_[0]); # don't break references as exceptions
my $i = short_error_loc();
if ($i) {
ret_summary($i, @_);