Git::Wrapper::Plus::Util - Misc plumbing tools for Git::Wrapper::Plus
version 0.004011
exit_status_handler
Git::Wrapper throws exceptions in a few cases, and some of these cases are considered normal flow control for Git::Wrapper::Plus.
Git::Wrapper
Git::Wrapper::Plus
For instance, some functions in git emit no output, and return an exit code.
git
Git::Wrapper treats that circumstance as a fatal exception!.
Its messy getting all the right try/catch stuff going, and checking for the object type, and then checking if the exception type is recognized or not, and only then determining if the status was white-listed.
try/catch
So:
use Git::Wrapper::Plus::Util qw(exit_status_handler); my $ok = exit_status_handler ( $code , { 1 => sub { undef } });
The above code normally executes $code, and returns 1 if no exception occurred.
$code
1
If an exception occurred, and it is not a Git::Wrapper::Exception, it is simply re-thrown.
Git::Wrapper::Exception
And for any status codes listed in the map, the attached sub is executed, and exit_status_handler propagates its return value.
sub
Any other circumstances ( like a status code not existing in the map ) are simply re-thrown.
Kent Fredric <kentnl@cpan.org>
This software is copyright (c) 2017 by Kent Fredric <kentfredric@gmail.com>.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Git::Wrapper::Plus, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Git::Wrapper::Plus
CPAN shell
perl -MCPAN -e shell install Git::Wrapper::Plus
For more information on module installation, please visit the detailed CPAN module installation guide.