summaryrefslogtreecommitdiff
path: root/examples/network/git2.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <carlos@cmartin.tk>2012-05-10 16:52:12 +0200
committerCarlos Martín Nieto <carlos@cmartin.tk>2012-05-10 16:52:12 +0200
commitfb49bdf9c7837892154bf7efdb3db6c3ec63e396 (patch)
treefea91fc6997d6e4cebc75a54a0cc22b1dc12fa3a /examples/network/git2.c
parenta9d9965b35710f865d77a13da1cf084d0c870b55 (diff)
downloadlibgit2-fb49bdf9c7837892154bf7efdb3db6c3ec63e396.tar.gz
examples: update network examples error handling
Use giterr_last() and make sure it's not NULL.
Diffstat (limited to 'examples/network/git2.c')
-rw-r--r--examples/network/git2.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/examples/network/git2.c b/examples/network/git2.c
index aeb0e8f4c..c694762a2 100644
--- a/examples/network/git2.c
+++ b/examples/network/git2.c
@@ -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);