Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Belfer <arrbee@arrbee.com>2012-03-07 04:14:31 +0400
committerRussell Belfer <arrbee@arrbee.com>2012-03-07 04:27:13 +0400
commitae9e29fde7e7d1c0c3e95bdabbb5c96fc71b1c71 (patch)
tree65d8215f898fc30b579b72d815e6adc78823dd6c /src/errors.c
parentcb8a79617b15e347f26d21cedde0f2b8670c1876 (diff)
Migrating diff to new error handling
Ended up migrating a bunch of upstream functions as well including vector, attr_file, and odb in order to get this to work right.
Diffstat (limited to 'src/errors.c')
-rw-r--r--src/errors.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/errors.c b/src/errors.c
index 548e44a32..0454856cf 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;