mirror of
https://git.proxmox.com/git/libgit2
synced 2025-08-03 05:30:40 +00:00
examples: update network examples error handling
Use giterr_last() and make sure it's not NULL.
This commit is contained in:
parent
a9d9965b35
commit
fb49bdf9c7
@ -30,8 +30,11 @@ int run_command(git_cb fn, int argc, char **argv)
|
||||
|
||||
// Run the command. If something goes wrong, print the error message to stderr
|
||||
error = fn(repo, argc, argv);
|
||||
if (error < GIT_SUCCESS)
|
||||
fprintf(stderr, "Bad news:\n %s\n", git_error_last()->message);
|
||||
if (error < GIT_SUCCESS) {
|
||||
if (giterr_last() == NULL)
|
||||
fprintf(stderr, "Error without message");
|
||||
else
|
||||
fprintf(stderr, "Bad news:\n %s\n", giterr_last()->message);
|
||||
|
||||
if(repo)
|
||||
git_repository_free(repo);
|
||||
|
Loading…
Reference in New Issue
Block a user