Permalink
Browse files

avoid having exceptions stringify to ""

  • Loading branch information...
1 parent ab4dd13 commit 6a90585b2dc8549efa13cfc0f8b82152402c6bea @rjbs rjbs committed Mar 31, 2012
Showing with 8 additions and 1 deletion.
  1. +8 −1 lib/Git/Wrapper.pm
View
@@ -253,10 +253,17 @@ package Git::Wrapper::Exception;
sub new { my $class = shift; bless { @_ } => $class }
use overload (
- q("") => 'error',
+ q("") => '_stringify',
fallback => 1,
);
+sub _stringify {
+ my ($self) = @_;
+ my $error = $self->error;
+ return $error if $error =~ /\S/;
+ return "git exited non-zero but had no output to stderr";
+}
+
sub output { join "", map { "$_\n" } @{ shift->{output} } }
sub error { join "", map { "$_\n" } @{ shift->{error} } }
sub status { shift->{status} }

0 comments on commit 6a90585

Please sign in to comment.