]>
git.proxmox.com Git - libgit2.git/blob - src/errors.c
18afff3b57dc4c1a2e800aae4b4f90e2434a9e88
2 * Copyright (C) 2009-2011 the libgit2 contributors
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.
8 #include "git2/thread-utils.h" /* for GIT_TLS */
9 #include "thread-utils.h" /* for GIT_TLS */
13 static GIT_TLS
char g_last_error
[1024];
19 {GIT_ERROR
, "Unspecified error"},
20 {GIT_ENOTOID
, "Input was not a properly formatted Git object id."},
21 {GIT_ENOTFOUND
, "Object does not exist in the scope searched."},
22 {GIT_ENOMEM
, "Not enough space available."},
23 {GIT_EOSERR
, "Consult the OS error information."},
24 {GIT_EOBJTYPE
, "The specified object is of invalid type"},
25 {GIT_EOBJCORRUPTED
, "The specified object has its data corrupted"},
26 {GIT_ENOTAREPO
, "The specified repository is invalid"},
27 {GIT_EINVALIDTYPE
, "The object or config variable type is invalid or doesn't match"},
28 {GIT_EMISSINGOBJDATA
, "The object cannot be written that because it's missing internal data"},
29 {GIT_EPACKCORRUPTED
, "The packfile for the ODB is corrupted"},
30 {GIT_EFLOCKFAIL
, "Failed to adquire or release a file lock"},
31 {GIT_EZLIB
, "The Z library failed to inflate/deflate an object's data"},
32 {GIT_EBUSY
, "The queried object is currently busy"},
33 {GIT_EINVALIDPATH
, "The path is invalid"},
34 {GIT_EBAREINDEX
, "The index file is not backed up by an existing repository"},
35 {GIT_EINVALIDREFNAME
, "The name of the reference is not valid"},
36 {GIT_EREFCORRUPTED
, "The specified reference has its data corrupted"},
37 {GIT_ETOONESTEDSYMREF
, "The specified symbolic reference is too deeply nested"},
38 {GIT_EPACKEDREFSCORRUPTED
, "The pack-refs file is either corrupted of its format is not currently supported"},
39 {GIT_EINVALIDPATH
, "The path is invalid" },
40 {GIT_EREVWALKOVER
, "The revision walker is empty; there are no more commits left to iterate"},
41 {GIT_EINVALIDREFSTATE
, "The state of the reference is not valid"},
42 {GIT_ENOTIMPLEMENTED
, "This feature has not been implemented yet"},
43 {GIT_EEXISTS
, "A reference with this name already exists"},
44 {GIT_EOVERFLOW
, "The given integer literal is too large to be parsed"},
45 {GIT_ENOTNUM
, "The given literal is not a valid number"},
46 {GIT_EAMBIGUOUSOIDPREFIX
, "The given oid prefix is ambiguous"},
49 const char *git_strerror(int num
)
53 if (num
== GIT_EOSERR
)
54 return strerror(errno
);
55 for (i
= 0; i
< ARRAY_SIZE(error_codes
); i
++)
56 if (num
== error_codes
[i
].num
)
57 return error_codes
[i
].str
;
59 return "Unknown error";
62 void git___rethrow(const char *msg
, ...)
65 char *old_error
= NULL
;
70 vsnprintf(new_error
, sizeof(new_error
), msg
, va
);
73 old_error
= git__strdup(g_last_error
);
74 snprintf(g_last_error
, sizeof(g_last_error
), "%s \n - %s", new_error
, old_error
);
78 void git___throw(const char *msg
, ...)
83 vsnprintf(g_last_error
, sizeof(g_last_error
), msg
, va
);
87 const char *git_lasterror(void)
95 void git_clearerror(void)
97 g_last_error
[0] = '\0';