]>
git.proxmox.com Git - libgit2.git/blob - include/git2/errors.h
6f5580253b044959984f9905132840c35832528e
2 * Copyright (C) the libgit2 contributors. All rights reserved.
4 * This file is part of libgit2, distributed under the GNU GPL v2 with
5 * a Linking Exception. For full terms see the included COPYING file.
7 #ifndef INCLUDE_git_errors_h__
8 #define INCLUDE_git_errors_h__
14 * @brief Git error handling routines and variables
20 /** Generic return codes */
22 GIT_OK
= 0, /**< No error */
24 GIT_ERROR
= -1, /**< Generic error */
25 GIT_ENOTFOUND
= -3, /**< Requested object could not be found */
26 GIT_EEXISTS
= -4, /**< Object exists preventing operation */
27 GIT_EAMBIGUOUS
= -5, /**< More than one object matches */
28 GIT_EBUFS
= -6, /**< Output buffer too short to hold data */
30 /* GIT_EUSER is a special error that is never generated by libgit2
31 * code. You can return it from a callback (e.g to stop an iteration)
32 * to know that it was generated by the callback and not by libgit2.
36 GIT_EBAREREPO
= -8, /**< Operation not allowed on bare repository */
37 GIT_EUNBORNBRANCH
= -9, /**< HEAD refers to branch with no commits */
38 GIT_EUNMERGED
= -10, /**< Merge in progress prevented operation */
39 GIT_ENONFASTFORWARD
= -11, /**< Reference was not fast-forwardable */
40 GIT_EINVALIDSPEC
= -12, /**< Name/ref spec was not in a valid format */
41 GIT_ECONFLICT
= -13, /**< Checkout conflicts prevented operation */
42 GIT_ELOCKED
= -14, /**< Lock file prevented operation */
43 GIT_EMODIFIED
= -15, /**< Reference value does not match expected */
44 GIT_EAUTH
= -16, /**< Authentication error */
45 GIT_ECERTIFICATE
= -17, /**< Server certificate is invalid */
46 GIT_EAPPLIED
= -18, /**< Patch/merge has already been applied */
47 GIT_EPEEL
= -19, /**< The requested peel operation is not possible */
48 GIT_EEOF
= -20, /**< Unexpected EOF */
49 GIT_EINVALID
= -21, /**< Invalid operation or input */
50 GIT_EUNCOMMITTED
= -22, /**< Uncommitted changes in index prevented operation */
51 GIT_EDIRECTORY
= -23, /**< The operation is not valid for a directory */
52 GIT_EMERGECONFLICT
= -24, /**< A merge conflict exists and cannot continue */
54 GIT_PASSTHROUGH
= -30, /**< Internal only */
55 GIT_ITEROVER
= -31, /**< Signals end of iteration with iterator */
56 GIT_RETRY
= -32, /**< Internal only */
57 GIT_EMISMATCH
= -33, /**< Hashsum mismatch in object */
61 * Structure to store extra details of the last error that occurred.
63 * This is kept on a per-thread basis if GIT_THREADS was defined when the
64 * library was build, otherwise one is kept globally for the library
110 * Return the last `git_error` object that was generated for the
111 * current thread or NULL if no error has occurred.
113 * @return A git_error object.
115 GIT_EXTERN(const git_error
*) giterr_last(void);
118 * Clear the last library error that occurred for this thread.
120 GIT_EXTERN(void) giterr_clear(void);
123 * Set the error message string for this thread.
125 * This function is public so that custom ODB backends and the like can
126 * relay an error message through libgit2. Most regular users of libgit2
127 * will never need to call this function -- actually, calling it in most
128 * circumstances (for example, calling from within a callback function)
129 * will just end up having the value overwritten by libgit2 internals.
131 * This error message is stored in thread-local storage and only applies
132 * to the particular thread that this libgit2 call is made from.
134 * @param error_class One of the `git_error_t` enum above describing the
135 * general subsystem that is responsible for the error.
136 * @param string The formatted error message to keep
138 GIT_EXTERN(void) giterr_set_str(int error_class
, const char *string
);
141 * Set the error message to a special value for memory allocation failure.
143 * The normal `giterr_set_str()` function attempts to `strdup()` the string
144 * that is passed in. This is not a good idea when the error in question
145 * is a memory allocation failure. That circumstance has a special setter
146 * function that sets the error string to a known and statically allocated
149 GIT_EXTERN(void) giterr_set_oom(void);