summaryrefslogtreecommitdiffstats
path: root/include/git2/errors.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/git2/errors.h')
-rw-r--r--include/git2/errors.h82
1 files changed, 22 insertions, 60 deletions
diff --git a/include/git2/errors.h b/include/git2/errors.h
index 7180852..52fa5f0 100644
--- a/include/git2/errors.h
+++ b/include/git2/errors.h
@@ -19,20 +19,20 @@ GIT_BEGIN_DECL
/** Generic return codes */
typedef enum {
- GIT_OK = 0, /**< No error */
+ GIT_OK = 0, /**< No error */
- GIT_ERROR = -1, /**< Generic error */
- GIT_ENOTFOUND = -3, /**< Requested object could not be found */
- GIT_EEXISTS = -4, /**< Object exists preventing operation */
- GIT_EAMBIGUOUS = -5, /**< More than one object matches */
- GIT_EBUFS = -6, /**< Output buffer too short to hold data */
+ GIT_ERROR = -1, /**< Generic error */
+ GIT_ENOTFOUND = -3, /**< Requested object could not be found */
+ GIT_EEXISTS = -4, /**< Object exists preventing operation */
+ GIT_EAMBIGUOUS = -5, /**< More than one object matches */
+ GIT_EBUFS = -6, /**< Output buffer too short to hold data */
/**
* GIT_EUSER is a special error that is never generated by libgit2
* code. You can return it from a callback (e.g to stop an iteration)
* to know that it was generated by the callback and not by libgit2.
*/
- GIT_EUSER = -7,
+ GIT_EUSER = -7,
GIT_EBAREREPO = -8, /**< Operation not allowed on bare repository */
GIT_EUNBORNBRANCH = -9, /**< HEAD refers to branch with no commits */
@@ -59,7 +59,10 @@ typedef enum {
GIT_EINDEXDIRTY = -34, /**< Unsaved changes in the index would be overwritten */
GIT_EAPPLYFAIL = -35, /**< Patch application failed */
GIT_EOWNER = -36, /**< The object is not owned by the current user */
- GIT_TIMEOUT = -37 /**< The operation timed out */
+ GIT_TIMEOUT = -37, /**< The operation timed out */
+ GIT_EUNCHANGED = -38, /**< There were no changes */
+ GIT_ENOTSUPPORTED = -39, /**< An option is not supported */
+ GIT_EREADONLY = -40 /**< The subject is read-only */
} git_error_code;
/**
@@ -118,63 +121,22 @@ typedef enum {
* Return the last `git_error` object that was generated for the
* current thread.
*
- * The default behaviour of this function is to return NULL if no previous error has occurred.
- * However, libgit2's error strings are not cleared aggressively, so a prior
- * (unrelated) error may be returned. This can be avoided by only calling
- * this function if the prior call to a libgit2 API returned an error.
+ * This function will never return NULL.
*
- * @return A git_error object.
- */
-GIT_EXTERN(const git_error *) git_error_last(void);
-
-/**
- * Clear the last library error that occurred for this thread.
- */
-GIT_EXTERN(void) git_error_clear(void);
-
-/**
- * Set the error message string for this thread, using `printf`-style
- * formatting.
- *
- * This function is public so that custom ODB backends and the like can
- * relay an error message through libgit2. Most regular users of libgit2
- * will never need to call this function -- actually, calling it in most
- * circumstances (for example, calling from within a callback function)
- * will just end up having the value overwritten by libgit2 internals.
+ * Callers should not rely on this to determine whether an error has
+ * occurred. For error checking, callers should examine the return
+ * codes of libgit2 functions.
*
- * This error message is stored in thread-local storage and only applies
- * to the particular thread that this libgit2 call is made from.
+ * This call can only reliably report error messages when an error
+ * has occurred. (It may contain stale information if it is called
+ * after a different function that succeeds.)
*
- * @param error_class One of the `git_error_t` enum above describing the
- * general subsystem that is responsible for the error.
- * @param fmt The `printf`-style format string; subsequent arguments must
- * be the arguments for the format string.
- */
-GIT_EXTERN(void) git_error_set(int error_class, const char *fmt, ...)
- GIT_FORMAT_PRINTF(2, 3);
-
-/**
- * Set the error message string for this thread. This function is like
- * `git_error_set` but takes a static string instead of a `printf`-style
- * format.
+ * The memory for this object is managed by libgit2. It should not
+ * be freed.
*
- * @param error_class One of the `git_error_t` enum above describing the
- * general subsystem that is responsible for the error.
- * @param string The error message to keep
- * @return 0 on success or -1 on failure
- */
-GIT_EXTERN(int) git_error_set_str(int error_class, const char *string);
-
-/**
- * Set the error message to a special value for memory allocation failure.
- *
- * The normal `git_error_set_str()` function attempts to `strdup()` the
- * string that is passed in. This is not a good idea when the error in
- * question is a memory allocation failure. That circumstance has a
- * special setter function that sets the error string to a known and
- * statically allocated internal value.
+ * @return A git_error object.
*/
-GIT_EXTERN(void) git_error_set_oom(void);
+GIT_EXTERN(const git_error *) git_error_last(void);
/** @} */
GIT_END_DECL