Deduplicate code for retrieving libgit2 errors