Hash :
647dfdb4
Author :
Date :
2019-01-10T22:13:07
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249
/*
* Copyright (C) the libgit2 contributors. All rights reserved.
*
* This file is part of libgit2, distributed under the GNU GPL v2 with
* a Linking Exception. For full terms see the included COPYING file.
*/
#ifndef INCLUDE_git_errors_h__
#define INCLUDE_git_errors_h__
#include "common.h"
/**
* @file git2/errors.h
* @brief Git error handling routines and variables
* @ingroup Git
* @{
*/
GIT_BEGIN_DECL
/** Generic return codes */
typedef enum {
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_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_EBAREREPO = -8, /**< Operation not allowed on bare repository */
GIT_EUNBORNBRANCH = -9, /**< HEAD refers to branch with no commits */
GIT_EUNMERGED = -10, /**< Merge in progress prevented operation */
GIT_ENONFASTFORWARD = -11, /**< Reference was not fast-forwardable */
GIT_EINVALIDSPEC = -12, /**< Name/ref spec was not in a valid format */
GIT_ECONFLICT = -13, /**< Checkout conflicts prevented operation */
GIT_ELOCKED = -14, /**< Lock file prevented operation */
GIT_EMODIFIED = -15, /**< Reference value does not match expected */
GIT_EAUTH = -16, /**< Authentication error */
GIT_ECERTIFICATE = -17, /**< Server certificate is invalid */
GIT_EAPPLIED = -18, /**< Patch/merge has already been applied */
GIT_EPEEL = -19, /**< The requested peel operation is not possible */
GIT_EEOF = -20, /**< Unexpected EOF */
GIT_EINVALID = -21, /**< Invalid operation or input */
GIT_EUNCOMMITTED = -22, /**< Uncommitted changes in index prevented operation */
GIT_EDIRECTORY = -23, /**< The operation is not valid for a directory */
GIT_EMERGECONFLICT = -24, /**< A merge conflict exists and cannot continue */
GIT_PASSTHROUGH = -30, /**< A user-configured callback refused to act */
GIT_ITEROVER = -31, /**< Signals end of iteration with iterator */
GIT_RETRY = -32, /**< Internal only */
GIT_EMISMATCH = -33, /**< Hashsum mismatch in object */
GIT_EINDEXDIRTY = -34, /**< Unsaved changes in the index would be overwritten */
GIT_EAPPLYFAIL = -35, /**< Patch application failed */
} git_error_code;
/**
* Structure to store extra details of the last error that occurred.
*
* This is kept on a per-thread basis if GIT_THREADS was defined when the
* library was build, otherwise one is kept globally for the library
*/
typedef struct {
char *message;
int klass;
} git_error;
/** Error classes */
typedef enum {
GIT_ERROR_NONE = 0,
GIT_ERROR_NOMEMORY,
GIT_ERROR_OS,
GIT_ERROR_INVALID,
GIT_ERROR_REFERENCE,
GIT_ERROR_ZLIB,
GIT_ERROR_REPOSITORY,
GIT_ERROR_CONFIG,
GIT_ERROR_REGEX,
GIT_ERROR_ODB,
GIT_ERROR_INDEX,
GIT_ERROR_OBJECT,
GIT_ERROR_NET,
GIT_ERROR_TAG,
GIT_ERROR_TREE,
GIT_ERROR_INDEXER,
GIT_ERROR_SSL,
GIT_ERROR_SUBMODULE,
GIT_ERROR_THREAD,
GIT_ERROR_STASH,
GIT_ERROR_CHECKOUT,
GIT_ERROR_FETCHHEAD,
GIT_ERROR_MERGE,
GIT_ERROR_SSH,
GIT_ERROR_FILTER,
GIT_ERROR_REVERT,
GIT_ERROR_CALLBACK,
GIT_ERROR_CHERRYPICK,
GIT_ERROR_DESCRIBE,
GIT_ERROR_REBASE,
GIT_ERROR_FILESYSTEM,
GIT_ERROR_PATCH,
GIT_ERROR_WORKTREE,
GIT_ERROR_SHA1
} git_error_t;
/** @name Error Functions
*
* These functions report or set error information.
*/
/**@{*/
/**
* 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.
*
* @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.
*
* 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.
*
* This error message is stored in thread-local storage and only applies
* to the particular thread that this libgit2 call is made from.
*
* @param error_class One of the `git_error_t` enum above describing the
* general subsystem that is responsible for the error.
* @param string The formatted error message to keep
*/
GIT_EXTERN(void) 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.
*/
GIT_EXTERN(void) git_error_set_oom(void);
/**@}*/
/** @name Deprecated Error Functions
*
* These functions and enumeration values are retained for backward
* compatibility. The newer versions of these functions should be
* preferred in all new code.
*/
/**@{*/
GIT_DEPRECATED(static const int) GITERR_NONE = GIT_ERROR_NONE;
GIT_DEPRECATED(static const int) GITERR_NOMEMORY = GIT_ERROR_NOMEMORY;
GIT_DEPRECATED(static const int) GITERR_OS = GIT_ERROR_OS;
GIT_DEPRECATED(static const int) GITERR_INVALID = GIT_ERROR_INVALID;
GIT_DEPRECATED(static const int) GITERR_REFERENCE = GIT_ERROR_REFERENCE;
GIT_DEPRECATED(static const int) GITERR_ZLIB = GIT_ERROR_ZLIB;
GIT_DEPRECATED(static const int) GITERR_REPOSITORY = GIT_ERROR_REPOSITORY;
GIT_DEPRECATED(static const int) GITERR_CONFIG = GIT_ERROR_CONFIG;
GIT_DEPRECATED(static const int) GITERR_REGEX = GIT_ERROR_REGEX;
GIT_DEPRECATED(static const int) GITERR_ODB = GIT_ERROR_ODB;
GIT_DEPRECATED(static const int) GITERR_INDEX = GIT_ERROR_INDEX;
GIT_DEPRECATED(static const int) GITERR_OBJECT = GIT_ERROR_OBJECT;
GIT_DEPRECATED(static const int) GITERR_NET = GIT_ERROR_NET;
GIT_DEPRECATED(static const int) GITERR_TAG = GIT_ERROR_TAG;
GIT_DEPRECATED(static const int) GITERR_TREE = GIT_ERROR_TREE;
GIT_DEPRECATED(static const int) GITERR_INDEXER = GIT_ERROR_INDEXER;
GIT_DEPRECATED(static const int) GITERR_SSL = GIT_ERROR_SSL;
GIT_DEPRECATED(static const int) GITERR_SUBMODULE = GIT_ERROR_SUBMODULE;
GIT_DEPRECATED(static const int) GITERR_THREAD = GIT_ERROR_THREAD;
GIT_DEPRECATED(static const int) GITERR_STASH = GIT_ERROR_STASH;
GIT_DEPRECATED(static const int) GITERR_CHECKOUT = GIT_ERROR_CHECKOUT;
GIT_DEPRECATED(static const int) GITERR_FETCHHEAD = GIT_ERROR_FETCHHEAD;
GIT_DEPRECATED(static const int) GITERR_MERGE = GIT_ERROR_MERGE;
GIT_DEPRECATED(static const int) GITERR_SSH = GIT_ERROR_SSH;
GIT_DEPRECATED(static const int) GITERR_FILTER = GIT_ERROR_FILTER;
GIT_DEPRECATED(static const int) GITERR_REVERT = GIT_ERROR_REVERT;
GIT_DEPRECATED(static const int) GITERR_CALLBACK = GIT_ERROR_CALLBACK;
GIT_DEPRECATED(static const int) GITERR_CHERRYPICK = GIT_ERROR_CHERRYPICK;
GIT_DEPRECATED(static const int) GITERR_DESCRIBE = GIT_ERROR_DESCRIBE;
GIT_DEPRECATED(static const int) GITERR_REBASE = GIT_ERROR_REBASE;
GIT_DEPRECATED(static const int) GITERR_FILESYSTEM = GIT_ERROR_FILESYSTEM;
GIT_DEPRECATED(static const int) GITERR_PATCH = GIT_ERROR_PATCH;
GIT_DEPRECATED(static const int) GITERR_WORKTREE = GIT_ERROR_WORKTREE;
GIT_DEPRECATED(static const int) GITERR_SHA1 = GIT_ERROR_SHA1;
/**
* Return the last `git_error` object that was generated for the
* current thread. This function is deprecated and will be removed
* in a future release; `git_error_last` should be used instead.
*
* @see git_error_last
*/
GIT_DEPRECATED(GIT_EXTERN(const git_error *)) giterr_last(void);
/**
* Clear the last error. This function is deprecated and will be
* removed in a future release; `giterr_clear` should be used instead.
*
* @see git_error_last
*/
GIT_DEPRECATED(GIT_EXTERN(void)) giterr_clear(void);
/**
* Sets the error message to the given string. This function is
* deprecated and will be removed in a future release; `giterr_clear`
* should be used instead.
*
* @see git_error_set_str
*/
GIT_DEPRECATED(GIT_EXTERN(void)) giterr_set_str(int error_class, const char *string);
/**
* Indicates that an out-of-memory situation occured. This function
* is deprecated and will be removed in a future release; `giterr_clear`
* should be used instead.
*
* @see git_error_set_oom
*/
GIT_DEPRECATED(GIT_EXTERN(void)) giterr_set_oom(void);
/**@}*/
/** @} */
GIT_END_DECL
#endif