]> git.proxmox.com Git - libgit2.git/blame - src/errors.c
I broke your bindings
[libgit2.git] / src / errors.c
CommitLineData
ae234862
AE
1#include "common.h"
2#include "thread-utils.h" /* for GIT_TLS */
3
ae234862
AE
4static struct {
5 int num;
6 const char *str;
7} error_codes[] = {
a8bfce69
VM
8 {GIT_ERROR, "Unspecified error"},
9 {GIT_ENOTOID, "Input was not a properly formatted Git object id."},
10 {GIT_ENOTFOUND, "Object does not exist in the scope searched."},
11 {GIT_ENOMEM, "Not enough space available."},
12 {GIT_EOSERR, "Consult the OS error information."},
13 {GIT_EOBJTYPE, "The specified object is of invalid type"},
14 {GIT_EOBJCORRUPTED, "The specified object has its data corrupted"},
15 {GIT_ENOTAREPO, "The specified repository is invalid"},
16 {GIT_EINVALIDTYPE, "The object type is invalid or doesn't match"},
17 {GIT_EMISSINGOBJDATA, "The object cannot be written that because it's missing internal data"},
18 {GIT_EPACKCORRUPTED, "The packfile for the ODB is corrupted"},
19 {GIT_EFLOCKFAIL, "Failed to adquire or release a file lock"},
20 {GIT_EZLIB, "The Z library failed to inflate/deflate an object's data"},
21 {GIT_EBUSY, "The queried object is currently busy"},
f2c24713 22 {GIT_EINVALIDPATH, "The path is invalid"},
9282e921 23 {GIT_EBAREINDEX, "The index file is not backed up by an existing repository"},
24 {GIT_EINVALIDREFNAME, "The name of the reference is not valid"},
25 {GIT_EREFCORRUPTED, "The specified reference has its data corrupted"},
26 {GIT_ETOONESTEDSYMREF, "The specified symbolic reference is too deeply nested"},
c836c332
VM
27 {GIT_EPACKEDREFSCORRUPTED, "The pack-refs file is either corrupted of its format is not currently supported"},
28 {GIT_EINVALIDPATH, "The path is invalid" },
6a0895ad 29 {GIT_EREVWALKOVER, "The revision walker is empty; there are no more commits left to iterate"},
72a3fe42
VM
30 {GIT_EINVALIDREFSTATE, "The state of the reference is not valid"},
31 {GIT_ENOTIMPLEMENTED, "This feature has not been implemented yet"}
ae234862
AE
32};
33
34const char *git_strerror(int num)
35{
0ef9d2aa 36 size_t i;
7dd8a9f7
SP
37
38 if (num == GIT_EOSERR)
39 return strerror(errno);
ae234862
AE
40 for (i = 0; i < ARRAY_SIZE(error_codes); i++)
41 if (num == error_codes[i].num)
42 return error_codes[i].str;
43
44 return "Unknown error";
45}