NAME

Git::Native::Error - Exception class for Git::Native

VERSION

version 0.004

SYNOPSIS

use Git::Native::Error;
Git::Native::Error->throw(
  code    => -3,
  klass   => 11,
  message => 'object not found',
);

DESCRIPTION

Throwable exception used by Git::Native when libgit2 reports an error. Attributes mirror the C git_error struct plus the return code.

check_rc

use Git::Native::Error qw( check_rc );
check_rc Git::Libgit2::FFI::some_call(...);

Pass-through for a non-negative return code; on a negative one it reads libgit2's thread-local error (a low-level Git::Libgit2::Error) and re-throws it as a Git::Native::Error. Every wrapper in the distribution routes its FFI int-returns through this so no raw libgit2 error object escapes the API.

is_not_found / is_exists / is_auth / is_certificate / is_conflict / is_not_fast_forward / is_unborn_branch / is_invalid_spec / is_not_matched

if ( my $err = $@ ) {
  return if $err->is_not_found;   # treat "missing" as empty
  die $err;
}

Predicates over code for the common failure kinds (GIT_ENOTFOUND, GIT_EEXISTS, GIT_EAUTH, GIT_ECERTIFICATE, GIT_ECONFLICT, GIT_ENONFASTFORWARD, GIT_EUNBORNBRANCH, GIT_EINVALIDSPEC, GIT_EMODIFIED). Each returns 1 or 0. For other codes compare $err->code against the GIT_E* constants exported by Git::Libgit2.

SUPPORT

Issues

Please report bugs and feature requests on GitHub at https://github.com/Getty/p5-git-native/issues.

CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

AUTHOR

Torsten Raudssus <getty@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Torsten Raudssus <torsten@raudssus.de> https://raudssus.de/.

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