diff options
author | Russell Belfer <rb@github.com> | 2013-12-04 04:45:39 +0400 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-12-11 22:57:49 +0400 |
commit | 96869a4edb2872934e0e167a726ab240f4270fea (patch) | |
tree | 2d770414acef2d1d45a609e004c0aa6fa56d06d7 /src/iterator.c | |
parent | 9f77b3f6f5ce6944ec49dfc666ef6b8df0af0c6b (diff) |
Improve GIT_EUSER handling
This adds giterr_user_cancel to return GIT_EUSER and clear any
error message that is sitting around. As a result of using that
in places, we need to be more thorough with capturing errors that
happen inside a callback when used internally. To help with that,
this also adds giterr_capture and giterr_restore so that when we
internally use a foreach-type function that clears errors and
converts them to GIT_EUSER, it is easier to restore not just the
return value, but the actual error message text.
Diffstat (limited to 'src/iterator.c')
-rw-r--r-- | src/iterator.c | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/src/iterator.c b/src/iterator.c index 8646399ab..c1292227c 100644 --- a/src/iterator.c +++ b/src/iterator.c @@ -991,9 +991,8 @@ static int fs_iterator__expand_dir(fs_iterator *fi) fi->base.start, fi->base.end, &ff->entries); if (error < 0) { - git_error last_error = {0}; - - giterr_detach(&last_error); + git_error_state last_error = { 0 }; + giterr_capture(&last_error, error); /* these callbacks may clear the error message */ fs_iterator__free_frame(ff); @@ -1001,12 +1000,7 @@ static int fs_iterator__expand_dir(fs_iterator *fi) /* next time return value we skipped to */ fi->base.flags &= ~GIT_ITERATOR_FIRST_ACCESS; - if (last_error.message) { - giterr_set_str(last_error.klass, last_error.message); - free(last_error.message); - } - - return error; + return giterr_restore(&last_error); } if (ff->entries.length == 0) { |