diff options
author | Russell Belfer <arrbee@arrbee.com> | 2012-03-06 16:14:31 -0800 |
---|---|---|
committer | Russell Belfer <arrbee@arrbee.com> | 2012-03-06 16:27:13 -0800 |
commit | ae9e29fde7e7d1c0c3e95bdabbb5c96fc71b1c71 (patch) | |
tree | 65d8215f898fc30b579b72d815e6adc78823dd6c /src/errors.c | |
parent | cb8a79617b15e347f26d21cedde0f2b8670c1876 (diff) | |
download | libgit2-ae9e29fde7e7d1c0c3e95bdabbb5c96fc71b1c71.tar.gz |
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.c | 9 |
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; |