diff options
author | Russell Belfer <arrbee@arrbee.com> | 2012-03-07 10:55:18 -0800 |
---|---|---|
committer | Russell Belfer <arrbee@arrbee.com> | 2012-03-07 10:55:18 -0800 |
commit | 6af24ce31f43c3621f11720704a078058665bc3f (patch) | |
tree | 9d180ee76c51c7fd41b7cd646254e114801770db /src/errors.c | |
parent | e54d8d8972ddfa886bfcf1a078d253b632debc72 (diff) | |
parent | 998f7b3dd76afbf462785a757b24a3554ad8534d (diff) | |
download | libgit2-6af24ce31f43c3621f11720704a078058665bc3f.tar.gz |
Merge pull request #590 from arrbee/new-error-handling
Migrating diff to new error handling
Diffstat (limited to 'src/errors.c')
-rw-r--r-- | src/errors.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/errors.c b/src/errors.c index 548e44a3..c25fa751 100644 --- a/src/errors.c +++ b/src/errors.c @@ -123,6 +123,8 @@ void giterr_set(int error_class, const char *string, ...) char error_str[1024]; va_list arglist; git_error *error; + const char *oserr = + (error_class == GITERR_OS && errno != 0) ? strerror(errno) : NULL; error = &GIT_GLOBAL->error_t; free(error->message); @@ -131,6 +133,13 @@ void giterr_set(int error_class, const char *string, ...) p_vsnprintf(error_str, sizeof(error_str), string, arglist); va_end(arglist); + /* automatically suffix strerror(errno) for GITERR_OS errors */ + if (oserr != NULL) { + strncat(error_str, ": ", sizeof(error_str)); + strncat(error_str, oserr, sizeof(error_str)); + errno = 0; + } + error->message = git__strdup(error_str); error->klass = error_class; |