File: Exception.pm

package info (click to toggle)
libgit-wrapper-perl 0.048-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 252 kB
  • sloc: perl: 481; makefile: 6
file content (113 lines) | stat: -rw-r--r-- 2,223 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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>.

=head2 status

Returns the non-zero exit code reported by git on error.

=head1 SEE ALSO

=head2 L<Git::Wrapper>

In particular, see the section on Error handling.

=head1 REPORTING BUGS & OTHER WAYS TO CONTRIBUTE

The code for this module is maintained on GitHub, at
L<https://github.com/genehack/Git-Wrapper>. If you have a patch, feel free to
fork the repository and submit a pull request. If you find a bug, please open
an issue on the project at GitHub. (We also watch the L<http://rt.cpan.org>
queue for Git::Wrapper, so feel free to use that bug reporting system if you
prefer)

=head1 AUTHORS

=over 4

=item *

Hans Dieter Pearcey <hdp@cpan.org>

=item *

Chris Prather <chris@prather.org>

=item *

John SJ Anderson <genehack@genehack.org>

=back

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by Hans Dieter Pearcey.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut