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