@@ -9,7 +9,7 @@ and a generic error code (-1) for all critical or non-specific failures
99(e.g. running out of memory or system corruption).
1010
1111When a negative value is returned, an error message is also set. The
12- message can be accessed via the ` giterr_last ` function which will return a
12+ message can be accessed via the ` git_error_last ` function which will return a
1313pointer to a ` git_error ` structure containing the error message text and
1414the class of error (i.e. what part of the library generated the error).
1515
@@ -51,7 +51,7 @@ look at the error message that was generated.
5151 int error = git_repository_open(&repo, "path/to/repo");
5252
5353 if (error < 0) {
54- fprintf (stderr, "Could not open repository: %s\n", giterr_last ()->message);
54+ fprintf (stderr, "Could not open repository: %s\n", git_error_last ()->message);
5555 exit(1);
5656 }
5757
@@ -75,7 +75,7 @@ at the specific error values to decide what to do.
7575 fprintf (stderr, "Could not find repository at path '%s'\n", path);
7676 else
7777 fprintf(stderr, "Unable to open repository: %s\n",
78- giterr_last ()->message);
78+ git_error_last ()->message);
7979 exit(1);
8080 }
8181
@@ -86,7 +86,7 @@ at the specific error values to decide what to do.
8686Some of the higher-level language bindings may use a range of information
8787from libgit2 to convert error return codes into exceptions, including the
8888specific error return codes and even the class of error and the error
89- message returned by ` giterr_last ` , but the full range of that logic is
89+ message returned by ` git_error_last ` , but the full range of that logic is
9090beyond the scope of this document.
9191
9292Example internal implementation
@@ -102,7 +102,7 @@ int git_repository_open(git_repository **repository, const char *path)
102102{
103103 /* perform some logic to open the repository * /
104104 if (p_exists(path) < 0) {
105- giterr_set(GITERR_REPOSITORY , "The path '%s' doesn't exist", path);
105+ git_error_set(GIT_ERROR_REPOSITORY , "The path '%s' doesn't exist", path);
106106 return GIT_ENOTFOUND;
107107 }
108108
@@ -113,7 +113,7 @@ int git_repository_open(git_repository **repository, const char *path)
113113The public error API
114114--------------------
115115
116- - `const git_error *giterr_last (void)`: The main function used to look up
116+ - `const git_error *git_error_last (void)`: The main function used to look up
117117 the last error. This may return NULL if no error has occurred.
118118 Otherwise this should return a `git_error` object indicating the class
119119 of error and the error message that was generated by the library.
@@ -133,22 +133,22 @@ The public error API
133133 bugs, but in the meantime, please code defensively and check for NULL
134134 when calling this function.
135135
136- - `void giterr_clear (void)`: This function clears the last error. The
136+ - `void git_error_clear (void)`: This function clears the last error. The
137137 library will call this when an error is generated by low level function
138138 and the higher level function handles the error.
139139
140140 _Note_ There are some known bugs in the library where a low level
141141 function's error message is not cleared by higher level code that
142142 handles the error and returns zero. Please report these as bugs, but in
143143 the meantime, a zero return value from a libgit2 API does not guarantee
144- that `giterr_last ()` will return NULL.
144+ that `git_error_last ()` will return NULL.
145145
146- - `void giterr_set_str (int error_class, const char *message)`: This
146+ - `void git_error_set (int error_class, const char *message)`: This
147147 function can be used when writing a custom backend module to set the
148148 libgit2 error message. See the documentation on this function for its
149149 use. Normal usage of libgit2 will probably never need to call this API.
150150
151- - `void giterr_set_oom (void)`: This is a standard function for reporting
151+ - `void git_error_set_oom (void)`: This is a standard function for reporting
152152 an out-of-memory error. It is written in a manner that it doesn't have
153153 to allocate any extra memory in order to record the error, so this is
154154 the best way to report that scenario.
@@ -182,18 +182,18 @@ There are some known bugs in the library where some functions may return a
182182negative value but not set an error message and some other functions may
183183return zero (no error) and yet leave an error message set. Please report
184184these cases as issues and they will be fixed. In the meanwhile, please
185- code defensively, checking that the return value of `giterr_last ` is not
186- NULL before using it, and not relying on `giterr_last ` to return NULL when
185+ code defensively, checking that the return value of `git_error_last ` is not
186+ NULL before using it, and not relying on `git_error_last ` to return NULL when
187187a function returns 0 for success.
188188
189189The internal error API
190190----------------------
191191
192- - `void giterr_set (int error_class, const char *fmt, ...)`: This is the
192+ - `void git_error_set (int error_class, const char *fmt, ...)`: This is the
193193 main internal function for setting an error. It works like `printf` to
194- format the error message. See the notes of `giterr_set_str ` for a
194+ format the error message. See the notes of `git_error_set_str ` for a
195195 general description of how error messages are stored (and also about
196- special handling for `error_class` of `GITERR_OS `).
196+ special handling for `error_class` of `GIT_ERROR_OS `).
197197
198198Writing error messages
199199----------------------
@@ -248,7 +248,7 @@ General guidelines for error reporting
248248 ...
249249
250250 if (git_commit_lookup(parent, repo, parent_id) < 0) {
251- giterr_set(GITERR_COMMIT , "Overwrite lookup error message");
251+ git_error_set(GIT_ERROR_COMMIT , "Overwrite lookup error message");
252252 return -1; /* mask error code */
253253 }
254254
0 commit comments