mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-03 00:43:41 +00:00
Improved error handling
Signed-off-by: Sven Strickroth <email@cs-ware.de>
This commit is contained in:
parent
89ad1c57a3
commit
bd25a302d3
11
src/errors.c
11
src/errors.c
@ -64,8 +64,15 @@ void giterr_set(int error_class, const char *string, ...)
|
||||
int utf8_size = WideCharToMultiByte(CP_UTF8, 0, lpMsgBuf, -1, NULL, 0, NULL, NULL);
|
||||
|
||||
char *lpMsgBuf_utf8 = git__malloc(utf8_size * sizeof(char));
|
||||
GITERR_CHECK_ALLOC(lpMsgBuf_utf8);
|
||||
WideCharToMultiByte(CP_UTF8, 0, lpMsgBuf, -1, lpMsgBuf_utf8, utf8_size, NULL, NULL);
|
||||
if (lpMsgBuf_utf8 == NULL) {
|
||||
LocalFree(lpMsgBuf);
|
||||
return;
|
||||
}
|
||||
if (!WideCharToMultiByte(CP_UTF8, 0, lpMsgBuf, -1, lpMsgBuf_utf8, utf8_size, NULL, NULL)) {
|
||||
LocalFree(lpMsgBuf);
|
||||
git__free(lpMsgBuf_utf8);
|
||||
return;
|
||||
}
|
||||
|
||||
git_buf_PUTS(&buf, ": ");
|
||||
git_buf_puts(&buf, lpMsgBuf_utf8);
|
||||
|
12
src/netops.c
12
src/netops.c
@ -48,8 +48,16 @@ static void net_set_error(const char *str)
|
||||
|
||||
int utf8_size = WideCharToMultiByte(CP_UTF8, 0, err_str, -1, NULL, 0, NULL, NULL);
|
||||
char * err_str_utf8 = git__malloc(utf8_size * sizeof(char));
|
||||
GITERR_CHECK_ALLOC(err_str_utf8);
|
||||
WideCharToMultiByte(CP_UTF8, 0, err_str, -1, err_str_utf8, utf8_size, NULL, NULL);
|
||||
if (err_str_utf8 == NULL) {
|
||||
LocalFree(err_str);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!WideCharToMultiByte(CP_UTF8, 0, err_str, -1, err_str_utf8, utf8_size, NULL, NULL)) {
|
||||
LocalFree(err_str);
|
||||
git__free(err_str_utf8);
|
||||
return;
|
||||
}
|
||||
|
||||
giterr_set(GITERR_NET, "%s: %s", str, err_str_utf8);
|
||||
LocalFree(err_str);
|
||||
|
Loading…
Reference in New Issue
Block a user