diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2020-01-18 18:00:39 +0000 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2020-01-24 15:12:56 -0600 |
commit | f78f6bd597bf0207a89d8defd4f0b9582830844c (patch) | |
tree | f9afaeb0c71b4f3e98f87a3ce1b812744f446713 /src/errors.c | |
parent | 4b331f020e29bf04525773c058e5015242c71eb5 (diff) | |
download | libgit2-f78f6bd597bf0207a89d8defd4f0b9582830844c.tar.gz |
error functions: return an int
Stop returning a void for functions, future-proofing them to allow them
to fail.
Diffstat (limited to 'src/errors.c')
-rw-r--r-- | src/errors.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/errors.c b/src/errors.c index c75f6b17a..b34aa3abb 100644 --- a/src/errors.c +++ b/src/errors.c @@ -95,19 +95,25 @@ void git_error_vset(int error_class, const char *fmt, va_list ap) set_error_from_buffer(error_class); } -void git_error_set_str(int error_class, const char *string) +int git_error_set_str(int error_class, const char *string) { git_buf *buf = &GIT_GLOBAL->error_buf; assert(string); - if (!string) - return; + if (!string) { + git_error_set(GIT_ERROR_INVALID, "unspecified caller error"); + return -1; + } git_buf_clear(buf); git_buf_puts(buf, string); - if (!git_buf_oom(buf)) - set_error_from_buffer(error_class); + + if (git_buf_oom(buf)) + return -1; + + set_error_from_buffer(error_class); + return 0; } void git_error_clear(void) |