Blob


1 /*
2 * Copyright (c) 2018 Stefan Sperling <stsp@openbsd.org>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
17 /* Error codes */
18 #define GOT_ERR_ERRNO 0
19 #define GOT_ERR_NO_MEM 1
20 #define GOT_ERR_NOT_GIT_REPO 2
21 #define GOT_ERR_NOT_ABSPATH 3
22 #define GOT_ERR_BAD_PATH 4
23 #define GOT_ERR_NOT_REF 5
24 #define GOT_ERR_IO 6
25 #define GOT_ERR_EOF 7
26 #define GOT_ERR_DECOMPRESSION 8
27 #define GOT_ERR_NO_SPACE 9
28 #define GOT_ERR_BAD_OBJ_HDR 10
29 #define GOT_ERR_OBJ_TYPE 11
30 #define GOT_ERR_BAD_OBJ_DATA 12
31 #define GOT_ERR_FILE_OPEN 13
32 #define GOT_ERR_BAD_PACKIDX 14
33 #define GOT_ERR_PACKIDX_CSUM 15
34 #define GOT_ERR_BAD_PACKFILE 16
35 #define GOT_ERR_NO_OBJ 17
36 #define GOT_ERR_NOT_IMPL 18
37 #define GOT_ERR_OBJ_NOT_PACKED 19
38 #define GOT_ERR_BAD_DELTA_CHAIN 20
39 #define GOT_ERR_BAD_DELTA 21
40 #define GOT_ERR_COMPRESSION 22
41 #define GOT_ERR_BAD_OBJ_ID_STR 23
43 static const struct got_error {
44 int code;
45 const char *msg;
46 } got_errors[] = {
47 { GOT_ERR_ERRNO, "see errno" },
48 { GOT_ERR_NO_MEM, "out of memory" },
49 { GOT_ERR_NOT_GIT_REPO, "no git repository found" },
50 { GOT_ERR_NOT_ABSPATH, "absolute path expected" },
51 { GOT_ERR_BAD_PATH, "bad path" },
52 { GOT_ERR_NOT_REF, "no such reference found" },
53 { GOT_ERR_IO, "input/output error" },
54 { GOT_ERR_EOF, "unexpected end of file" },
55 { GOT_ERR_DECOMPRESSION,"decompression failed" },
56 { GOT_ERR_NO_SPACE, "buffer too small" },
57 { GOT_ERR_BAD_OBJ_HDR, "bad object header" },
58 { GOT_ERR_OBJ_TYPE, "wrong type of object" },
59 { GOT_ERR_BAD_OBJ_DATA, "bad object data" },
60 { GOT_ERR_FILE_OPEN, "could not open file" },
61 { GOT_ERR_BAD_PACKIDX, "bad pack index file" },
62 { GOT_ERR_PACKIDX_CSUM, "pack index file checksum error" },
63 { GOT_ERR_BAD_PACKFILE, "bad pack file" },
64 { GOT_ERR_NO_OBJ, "object not found" },
65 { GOT_ERR_NOT_IMPL, "feature not implemented" },
66 { GOT_ERR_OBJ_NOT_PACKED,"object is not packed" },
67 { GOT_ERR_BAD_DELTA_CHAIN,"bad delta chain" },
68 { GOT_ERR_BAD_DELTA, "bad delta" },
69 { GOT_ERR_COMPRESSION, "compression failed" },
70 { GOT_ERR_BAD_OBJ_ID_STR,"bad object id string" },
71 };
73 const struct got_error * got_error(int code);
74 const struct got_error *got_error_from_errno();
75 const struct got_error *got_ferror(FILE *, int);