Git-Wrapper

 view release on metacpan or  search on metacpan

lib/Git/Wrapper/Exception.pm  view on Meta::CPAN

package Git::Wrapper::Exception;
# ABSTRACT: Exception class for Git::Wrapper
$Git::Wrapper::Exception::VERSION = '0.048';
use 5.006;
use strict;
use warnings;

sub new { my $class = shift; bless { @_ } => $class }

use overload (
  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} }

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

Git::Wrapper::Exception - Exception class for Git::Wrapper

=head1 VERSION

version 0.048

=head1 SYNOPSIS

A new error object may be generated and thrown as follows:

  die Git::Wrapper::Exception->new(
    output => \@out,   # STDOUT
    error  => \@err,   # STERR
    status => $? >> 8, # git process exist status
  );

=head1 METHODS

=head2 new

The standard constructor for this class.

=head2 error

Returns the full error message reported by the resulting git command sent to
C<STDERR>.

=head2 output

Returns the full output generated by the git command that is sent to C<STDOUT>.

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.715 second using v1.00-cache-2.02-grep-82fe00e-cpan-f5108d614456 )