Skip to content

Commit

Permalink
Display errno when syscalls fails
Browse files Browse the repository at this point in the history
  • Loading branch information
gisle committed Jan 12, 2009
1 parent 71489bc commit af73bed
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions lib/Data/Dump/Trace.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@ $VERSION = "0.01";

# Todo:
# - prototypes
# in/out parameters
# key/value style parameters or return values
# globals affected ($!)
# in/out parameters key/value style
# - exception
# - wrap class
# - autowrap in list return
# - don't dump return values
# - configurable colors
# - show call depth using indentation
# - show nested calls sensibly
Expand Down Expand Up @@ -120,6 +116,7 @@ use Data::Dump ();
our %COLOR = (
name => "yellow",
output => "cyan",
error => "red",
debug => "red",
);

Expand Down Expand Up @@ -234,7 +231,11 @@ sub return_scalar {
$s = Data::Dump::Trace::wrap(name => $name, obj => $s, prototypes => $wrap->{prototypes});
}
else {
print " = ", $self->color("output", _dump($s)), "\n";
print " = ", $self->color("output", _dump($s));
if (!$s && $proto_ret =~ /!/ && $!) {
print " ", $self->color("error", errno($!));
}
print "\n";
}
return $s;
}
Expand All @@ -247,6 +248,18 @@ sub return_list {
return @_;
}

sub errno {
my $t = "";
for (keys %!) {
if ($!{$_}) {
$t = $_;
last;
}
}
my $n = int($!);
return "$t($n) $!";
}

1;

__END__
Expand Down

0 comments on commit af73bed

Please sign in to comment.