]> git.proxmox.com Git - libgit2.git/blob - src/errors.c
Merge branch 'waf-pkgconfig-typo' of https://github.com/marvil07/libgit2
[libgit2.git] / src / errors.c
1 #include "common.h"
2 #include "thread-utils.h" /* for GIT_TLS */
3
4 static struct {
5 int num;
6 const char *str;
7 } error_codes[] = {
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"},
22 };
23
24 const char *git_strerror(int num)
25 {
26 size_t i;
27
28 if (num == GIT_EOSERR)
29 return strerror(errno);
30 for (i = 0; i < ARRAY_SIZE(error_codes); i++)
31 if (num == error_codes[i].num)
32 return error_codes[i].str;
33
34 return "Unknown error";
35 }