]> git.proxmox.com Git - libgit2.git/blob - include/git2/errors.h
error-handling: On-disk config file backend
[libgit2.git] / include / git2 / errors.h
1 /*
2 * Copyright (C) 2009-2012 the libgit2 contributors
3 *
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.
6 */
7 #ifndef INCLUDE_git_errors_h__
8 #define INCLUDE_git_errors_h__
9
10 #include "common.h"
11
12 /**
13 * @file git2/errors.h
14 * @brief Git error handling routines and variables
15 * @ingroup Git
16 * @{
17 */
18 GIT_BEGIN_DECL
19
20 typedef enum {
21 GIT_SUCCESS = 0,
22 GIT_ERROR = -1,
23
24 /** Input was not a properly formatted Git object id. */
25 GIT_ENOTOID = -2,
26
27 /** Input does not exist in the scope searched. */
28 GIT_ENOTFOUND = -3,
29
30 /** Not enough space available. */
31 GIT_ENOMEM = -4,
32
33 /** Consult the OS error information. */
34 GIT_EOSERR = -5,
35
36 /** The specified object is of invalid type */
37 GIT_EOBJTYPE = -6,
38
39 /** The specified repository is invalid */
40 GIT_ENOTAREPO = -7,
41
42 /** The object type is invalid or doesn't match */
43 GIT_EINVALIDTYPE = -8,
44
45 /** The object cannot be written because it's missing internal data */
46 GIT_EMISSINGOBJDATA = -9,
47
48 /** The packfile for the ODB is corrupted */
49 GIT_EPACKCORRUPTED = -10,
50
51 /** Failed to acquire or release a file lock */
52 GIT_EFLOCKFAIL = -11,
53
54 /** The Z library failed to inflate/deflate an object's data */
55 GIT_EZLIB = -12,
56
57 /** The queried object is currently busy */
58 GIT_EBUSY = -13,
59
60 /** The index file is not backed up by an existing repository */
61 GIT_EBAREINDEX = -14,
62
63 /** The name of the reference is not valid */
64 GIT_EINVALIDREFNAME = -15,
65
66 /** The specified reference has its data corrupted */
67 GIT_EREFCORRUPTED = -16,
68
69 /** The specified symbolic reference is too deeply nested */
70 GIT_ETOONESTEDSYMREF = -17,
71
72 /** The pack-refs file is either corrupted or its format is not currently supported */
73 GIT_EPACKEDREFSCORRUPTED = -18,
74
75 /** The path is invalid */
76 GIT_EINVALIDPATH = -19,
77
78 /** The revision walker is empty; there are no more commits left to iterate */
79 GIT_EREVWALKOVER = -20,
80
81 /** The state of the reference is not valid */
82 GIT_EINVALIDREFSTATE = -21,
83
84 /** This feature has not been implemented yet */
85 GIT_ENOTIMPLEMENTED = -22,
86
87 /** A reference with this name already exists */
88 GIT_EEXISTS = -23,
89
90 /** The given integer literal is too large to be parsed */
91 GIT_EOVERFLOW = -24,
92
93 /** The given literal is not a valid number */
94 GIT_ENOTNUM = -25,
95
96 /** Streaming error */
97 GIT_ESTREAM = -26,
98
99 /** invalid arguments to function */
100 GIT_EINVALIDARGS = -27,
101
102 /** The specified object has its data corrupted */
103 GIT_EOBJCORRUPTED = -28,
104
105 /** The given short oid is ambiguous */
106 GIT_EAMBIGUOUSOIDPREFIX = -29,
107
108 /** Skip and passthrough the given ODB backend */
109 GIT_EPASSTHROUGH = -30,
110
111 /** The path pattern and string did not match */
112 GIT_ENOMATCH = -31,
113
114 /** The buffer is too short to satisfy the request */
115 GIT_ESHORTBUFFER = -32,
116 } git_error_t;
117
118 typedef struct {
119 char *message;
120 int klass;
121 } git_error;
122
123 typedef enum {
124 GITERR_NOMEMORY,
125 GITERR_OS,
126 GITERR_REFERENCE,
127 GITERR_ZLIB,
128 GITERR_REPOSITORY,
129 GITERR_CONFIG,
130 GITERR_REGEX,
131 } git_error_class;
132
133 /**
134 * Return a detailed error string with the latest error
135 * that occurred in the library.
136 * @return a string explaining the error
137 */
138 GIT_EXTERN(const char *) git_lasterror(void);
139
140 /**
141 * strerror() for the Git library
142 *
143 * Get a string description for a given error code.
144 * NOTE: This method will be eventually deprecated in favor
145 * of the new `git_lasterror`.
146 *
147 * @param num The error code to explain
148 * @return a string explaining the error code
149 */
150 GIT_EXTERN(const char *) git_strerror(int num);
151
152 /**
153 * Clear the latest library error
154 */
155 GIT_EXTERN(void) git_clearerror(void);
156
157 /** @} */
158 GIT_END_DECL
159 #endif