Blob


1 /*
2 * Copyright (c) 2018, 2019, 2020 Stefan Sperling <stsp@openbsd.org>
3 * Copyright (c) 2020 Ori Bernstein <ori@openbsd.org>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
18 #include "got_compat.h"
20 /* Error codes */
21 #define GOT_ERR_OK 0
22 #define GOT_ERR_ERRNO 1
23 #define GOT_ERR_NOT_GIT_REPO 2
24 #define GOT_ERR_BAD_FILETYPE 3
25 #define GOT_ERR_BAD_PATH 4
26 #define GOT_ERR_NOT_REF 5
27 #define GOT_ERR_IO 6
28 #define GOT_ERR_EOF 7
29 #define GOT_ERR_DECOMPRESSION 8
30 #define GOT_ERR_NO_SPACE 9
31 #define GOT_ERR_BAD_OBJ_HDR 10
32 #define GOT_ERR_OBJ_TYPE 11
33 #define GOT_ERR_BAD_OBJ_DATA 12
34 #define GOT_ERR_AMBIGUOUS_ID 13
35 #define GOT_ERR_BAD_PACKIDX 14
36 #define GOT_ERR_PACKIDX_CSUM 15
37 #define GOT_ERR_BAD_PACKFILE 16
38 #define GOT_ERR_NO_OBJ 17
39 #define GOT_ERR_NOT_IMPL 18
40 #define GOT_ERR_OBJ_NOT_PACKED 19
41 #define GOT_ERR_BAD_DELTA_CHAIN 20
42 #define GOT_ERR_BAD_DELTA 21
43 #define GOT_ERR_COMPRESSION 22
44 #define GOT_ERR_BAD_OBJ_ID_STR 23
45 #define GOT_ERR_WORKTREE_EXISTS 26
46 #define GOT_ERR_WORKTREE_META 27
47 #define GOT_ERR_WORKTREE_VERS 28
48 #define GOT_ERR_WORKTREE_BUSY 29
49 #define GOT_ERR_DIR_OBSTRUCTED 30
50 #define GOT_ERR_FILE_OBSTRUCTED 31
51 #define GOT_ERR_RECURSION 32
52 #define GOT_ERR_TIMEOUT 33
53 #define GOT_ERR_INTERRUPT 34
54 #define GOT_ERR_PRIVSEP_READ 35
55 #define GOT_ERR_PRIVSEP_LEN 36
56 #define GOT_ERR_PRIVSEP_PIPE 37
57 #define GOT_ERR_PRIVSEP_NO_FD 38
58 #define GOT_ERR_PRIVSEP_MSG 39
59 #define GOT_ERR_PRIVSEP_DIED 40
60 #define GOT_ERR_PRIVSEP_EXIT 41
61 #define GOT_ERR_PACK_OFFSET 42
62 #define GOT_ERR_OBJ_EXISTS 43
63 #define GOT_ERR_BAD_OBJ_ID 44
64 #define GOT_ERR_ITER_BUSY 45
65 #define GOT_ERR_ITER_COMPLETED 46
66 #define GOT_ERR_RANGE 47
67 #define GOT_ERR_EXPECTED 48 /* for use in regress tests only */
68 #define GOT_ERR_CANCELLED 49
69 #define GOT_ERR_NO_TREE_ENTRY 50
70 #define GOT_ERR_FILEIDX_SIG 51
71 #define GOT_ERR_FILEIDX_VER 52
72 #define GOT_ERR_FILEIDX_CSUM 53
73 #define GOT_ERR_PATH_PREFIX 54
74 #define GOT_ERR_ANCESTRY 55
75 #define GOT_ERR_FILEIDX_BAD 56
76 #define GOT_ERR_BAD_REF_DATA 57
77 #define GOT_ERR_TREE_DUP_ENTRY 58
78 #define GOT_ERR_DIR_DUP_ENTRY 59
79 #define GOT_ERR_NOT_WORKTREE 60
80 #define GOT_ERR_UUID_VERSION 61
81 #define GOT_ERR_UUID_INVALID 62
82 #define GOT_ERR_UUID 63
83 #define GOT_ERR_LOCKFILE_TIMEOUT 64
84 #define GOT_ERR_BAD_REF_NAME 65
85 #define GOT_ERR_WORKTREE_REPO 66
86 #define GOT_ERR_FILE_MODIFIED 67
87 #define GOT_ERR_FILE_STATUS 68
88 #define GOT_ERR_COMMIT_CONFLICT 69
89 #define GOT_ERR_BAD_REF_TYPE 70
90 #define GOT_ERR_COMMIT_NO_AUTHOR 71
91 #define GOT_ERR_COMMIT_HEAD_CHANGED 72
92 #define GOT_ERR_COMMIT_OUT_OF_DATE 73
93 #define GOT_ERR_COMMIT_MSG_EMPTY 74
94 #define GOT_ERR_DIR_NOT_EMPTY 75
95 #define GOT_ERR_COMMIT_NO_CHANGES 76
96 #define GOT_ERR_BRANCH_MOVED 77
97 #define GOT_ERR_OBJ_TOO_LARGE 78
98 #define GOT_ERR_SAME_BRANCH 79
99 #define GOT_ERR_ROOT_COMMIT 80
100 #define GOT_ERR_MIXED_COMMITS 81
101 #define GOT_ERR_CONFLICTS 82
102 #define GOT_ERR_BRANCH_EXISTS 83
103 #define GOT_ERR_MODIFIED 84
104 #define GOT_ERR_NOT_REBASING 85
105 #define GOT_ERR_EMPTY_REBASE 86
106 #define GOT_ERR_REBASE_COMMITID 87
107 #define GOT_ERR_REBASING 88
108 #define GOT_ERR_REBASE_PATH 89
109 #define GOT_ERR_NOT_HISTEDIT 90
110 #define GOT_ERR_EMPTY_HISTEDIT 91
111 #define GOT_ERR_NO_HISTEDIT_CMD 92
112 #define GOT_ERR_HISTEDIT_SYNTAX 93
113 #define GOT_ERR_HISTEDIT_CANCEL 94
114 /* 95 is currently unused */
115 #define GOT_ERR_HISTEDIT_BUSY 96
116 #define GOT_ERR_HISTEDIT_CMD 97
117 #define GOT_ERR_HISTEDIT_PATH 98
118 /* 99 is currently unused */
119 #define GOT_ERR_COMMIT_BRANCH 100
120 #define GOT_ERR_FILE_STAGED 101
121 #define GOT_ERR_STAGE_NO_CHANGE 102
122 #define GOT_ERR_STAGE_CONFLICT 103
123 #define GOT_ERR_STAGE_OUT_OF_DATE 104
124 #define GOT_ERR_FILE_NOT_STAGED 105
125 #define GOT_ERR_STAGED_PATHS 106
126 #define GOT_ERR_PATCH_CHOICE 107
127 #define GOT_ERR_COMMIT_NO_EMAIL 108
128 #define GOT_ERR_TAG_EXISTS 109
129 #define GOT_ERR_GIT_REPO_FORMAT 110
130 #define GOT_ERR_REBASE_REQUIRED 111
131 #define GOT_ERR_REGEX 112
132 #define GOT_ERR_REF_NAME_MINUS 113
133 #define GOT_ERR_GITCONFIG_SYNTAX 114
134 #define GOT_ERR_REBASE_OUT_OF_DATE 115
135 #define GOT_ERR_CACHE_DUP_ENTRY 116
136 #define GOT_ERR_QUERYSTRING 117
137 #define GOT_ERR_FETCH_FAILED 118
138 #define GOT_ERR_PARSE_URI 119
139 #define GOT_ERR_BAD_PROTO 120
140 #define GOT_ERR_ADDRINFO 121
141 #define GOT_ERR_BAD_PACKET 122
142 #define GOT_ERR_NO_REMOTE 123
143 #define GOT_ERR_FETCH_NO_BRANCH 124
144 #define GOT_ERR_FETCH_BAD_REF 125
145 #define GOT_ERR_TREE_ENTRY_TYPE 126
146 #define GOT_ERR_PARSE_CONFIG 127
147 #define GOT_ERR_NO_CONFIG_FILE 128
148 #define GOT_ERR_BAD_SYMLINK 129
149 #define GOT_ERR_GIT_REPO_EXT 130
150 #define GOT_ERR_CANNOT_PACK 131
151 #define GOT_ERR_LONELY_PACKIDX 132
152 #define GOT_ERR_OBJ_CSUM 133
153 #define GOT_ERR_SEND_BAD_REF 134
154 #define GOT_ERR_SEND_FAILED 135
155 #define GOT_ERR_SEND_EMPTY 136
156 #define GOT_ERR_SEND_ANCESTRY 137
157 #define GOT_ERR_CAPA_DELETE_REFS 138
158 #define GOT_ERR_SEND_DELETE_REF 139
159 #define GOT_ERR_SEND_TAG_EXISTS 140
160 #define GOT_ERR_NOT_MERGING 141
161 #define GOT_ERR_MERGE_OUT_OF_DATE 142
162 #define GOT_ERR_MERGE_STAGED_PATHS 143
163 #define GOT_ERR_MERGE_COMMIT_OUT_OF_DATE 143
164 #define GOT_ERR_MERGE_BUSY 144
165 #define GOT_ERR_MERGE_PATH 145
167 static const struct got_error {
168 int code;
169 const char *msg;
170 } got_errors[] = {
171 { GOT_ERR_OK, "no error occured?!?" },
172 { GOT_ERR_ERRNO, "see errno" },
173 { GOT_ERR_NOT_GIT_REPO, "no git repository found" },
174 { GOT_ERR_BAD_FILETYPE, "bad file type" },
175 { GOT_ERR_BAD_PATH, "bad path" },
176 { GOT_ERR_NOT_REF, "no such reference found" },
177 { GOT_ERR_IO, "input/output error" },
178 { GOT_ERR_EOF, "unexpected end of file" },
179 { GOT_ERR_DECOMPRESSION,"decompression failed" },
180 { GOT_ERR_NO_SPACE, "buffer too small" },
181 { GOT_ERR_BAD_OBJ_HDR, "bad object header" },
182 { GOT_ERR_OBJ_TYPE, "wrong type of object" },
183 { GOT_ERR_BAD_OBJ_DATA, "bad object data" },
184 { GOT_ERR_AMBIGUOUS_ID, "ambiguous object ID" },
185 { GOT_ERR_BAD_PACKIDX, "bad pack index file" },
186 { GOT_ERR_PACKIDX_CSUM, "pack index file checksum error" },
187 { GOT_ERR_BAD_PACKFILE, "bad pack file" },
188 { GOT_ERR_NO_OBJ, "object not found" },
189 { GOT_ERR_NOT_IMPL, "feature not implemented" },
190 { GOT_ERR_OBJ_NOT_PACKED,"object is not packed" },
191 { GOT_ERR_BAD_DELTA_CHAIN,"bad delta chain" },
192 { GOT_ERR_BAD_DELTA, "bad delta" },
193 { GOT_ERR_COMPRESSION, "compression failed" },
194 { GOT_ERR_BAD_OBJ_ID_STR,"bad object id string" },
195 { GOT_ERR_WORKTREE_EXISTS,"worktree already exists" },
196 { GOT_ERR_WORKTREE_META,"bad worktree meta data" },
197 { GOT_ERR_WORKTREE_VERS,"unsupported worktree format version" },
198 { GOT_ERR_WORKTREE_BUSY,"worktree already locked" },
199 { GOT_ERR_FILE_OBSTRUCTED,"file is obstructed" },
200 { GOT_ERR_RECURSION, "recursion limit reached" },
201 { GOT_ERR_TIMEOUT, "operation timed out" },
202 { GOT_ERR_INTERRUPT, "operation interrupted" },
203 { GOT_ERR_PRIVSEP_READ, "no data received in imsg" },
204 { GOT_ERR_PRIVSEP_LEN, "unexpected amount of data received in imsg" },
205 { GOT_ERR_PRIVSEP_PIPE, "privsep peer process closed pipe" },
206 { GOT_ERR_PRIVSEP_NO_FD,"privsep file descriptor unavailable" },
207 { GOT_ERR_PRIVSEP_MSG, "received unexpected privsep message" },
208 { GOT_ERR_PRIVSEP_DIED, "unprivileged process died unexpectedly" },
209 { GOT_ERR_PRIVSEP_EXIT, "bad exit code from unprivileged process" },
210 { GOT_ERR_PACK_OFFSET, "bad offset in pack file" },
211 { GOT_ERR_OBJ_EXISTS, "object already exists" },
212 { GOT_ERR_BAD_OBJ_ID, "bad object id" },
213 { GOT_ERR_ITER_BUSY, "iteration already in progress" },
214 { GOT_ERR_ITER_COMPLETED,"iteration completed" },
215 { GOT_ERR_RANGE, "value out of range" },
216 { GOT_ERR_EXPECTED, "expected an error but have no error" },
217 { GOT_ERR_CANCELLED, "operation in progress has been cancelled" },
218 { GOT_ERR_NO_TREE_ENTRY,"no such entry found in tree" },
219 { GOT_ERR_FILEIDX_SIG, "bad file index signature" },
220 { GOT_ERR_FILEIDX_VER, "unknown file index format version" },
221 { GOT_ERR_FILEIDX_CSUM, "bad file index checksum" },
222 { GOT_ERR_PATH_PREFIX, "worktree already contains items from a "
223 "different path prefix" },
224 { GOT_ERR_ANCESTRY, "target commit is on a different branch" },
225 { GOT_ERR_FILEIDX_BAD, "file index is corrupt" },
226 { GOT_ERR_BAD_REF_DATA, "could not parse reference data" },
227 { GOT_ERR_TREE_DUP_ENTRY,"duplicate entry in tree object" },
228 { GOT_ERR_DIR_DUP_ENTRY,"duplicate entry in directory" },
229 { GOT_ERR_NOT_WORKTREE, "no got work tree found" },
230 { GOT_ERR_UUID_VERSION, "bad uuid version" },
231 { GOT_ERR_UUID_INVALID, "uuid invalid" },
232 { GOT_ERR_UUID, "uuid error" },
233 { GOT_ERR_LOCKFILE_TIMEOUT,"lockfile timeout" },
234 { GOT_ERR_BAD_REF_NAME, "bad reference name" },
235 { GOT_ERR_WORKTREE_REPO,"cannot create worktree inside a git repository" },
236 { GOT_ERR_FILE_MODIFIED,"file contains modifications" },
237 { GOT_ERR_FILE_STATUS, "file has unexpected status" },
238 { GOT_ERR_COMMIT_CONFLICT,"cannot commit file in conflicted status" },
239 { GOT_ERR_BAD_REF_TYPE, "bad reference type" },
240 { GOT_ERR_COMMIT_NO_AUTHOR,"GOT_AUTHOR environment variable is not set" },
241 { GOT_ERR_COMMIT_HEAD_CHANGED, "branch head in repository has changed "
242 "while commit was in progress" },
243 { GOT_ERR_COMMIT_OUT_OF_DATE, "work tree must be updated before these "
244 "changes can be committed" },
245 { GOT_ERR_COMMIT_MSG_EMPTY, "commit message cannot be empty" },
246 { GOT_ERR_DIR_NOT_EMPTY, "directory exists and is not empty" },
247 { GOT_ERR_COMMIT_NO_CHANGES, "no changes to commit" },
248 { GOT_ERR_BRANCH_MOVED, "work tree's head reference now points to a "
249 "different branch; new head reference and/or update -b required" },
250 { GOT_ERR_OBJ_TOO_LARGE, "object too large" },
251 { GOT_ERR_SAME_BRANCH, "commit is already contained in this branch" },
252 { GOT_ERR_ROOT_COMMIT, "specified commit has no parent commit" },
253 { GOT_ERR_MIXED_COMMITS,"work tree contains files from multiple "
254 "base commits; the entire work tree must be updated first" },
255 { GOT_ERR_CONFLICTS, "work tree contains conflicted files; these "
256 "conflicts must be resolved first" },
257 { GOT_ERR_BRANCH_EXISTS,"specified branch already exists" },
258 { GOT_ERR_MODIFIED, "work tree contains local changes; these "
259 "changes must be committed or reverted first" },
260 { GOT_ERR_NOT_REBASING, "rebase operation not in progress" },
261 { GOT_ERR_EMPTY_REBASE, "no commits to rebase" },
262 { GOT_ERR_REBASE_COMMITID,"rebase commit ID mismatch" },
263 { GOT_ERR_REBASING, "a rebase operation is in progress in this "
264 "work tree and must be continued or aborted first" },
265 { GOT_ERR_REBASE_PATH, "cannot rebase branch which contains "
266 "changes outside of this work tree's path prefix" },
267 { GOT_ERR_NOT_HISTEDIT, "histedit operation not in progress" },
268 { GOT_ERR_EMPTY_HISTEDIT,"no commits to edit; perhaps the work tree "
269 "must be updated to an older commit first" },
270 { GOT_ERR_NO_HISTEDIT_CMD,"no histedit commands provided" },
271 { GOT_ERR_HISTEDIT_SYNTAX,"syntax error in histedit command list" },
272 { GOT_ERR_HISTEDIT_CANCEL,"histedit operation cancelled" },
273 { 95, "unused error code" },
274 { GOT_ERR_HISTEDIT_BUSY,"histedit operation is in progress in this "
275 "work tree and must be continued or aborted first" },
276 { GOT_ERR_HISTEDIT_CMD, "bad histedit command" },
277 { GOT_ERR_HISTEDIT_PATH, "cannot edit branch history which contains "
278 "changes outside of this work tree's path prefix" },
279 { 99, "unused error code" },
280 { GOT_ERR_COMMIT_BRANCH, "will not commit to a branch outside the "
281 "\"refs/heads/\" reference namespace" },
282 { GOT_ERR_FILE_STAGED, "file is staged" },
283 { GOT_ERR_STAGE_NO_CHANGE, "no changes to stage" },
284 { GOT_ERR_STAGE_CONFLICT, "cannot stage file in conflicted status" },
285 { GOT_ERR_STAGE_OUT_OF_DATE, "work tree must be updated before "
286 "changes can be staged" },
287 { GOT_ERR_FILE_NOT_STAGED, "file is not staged" },
288 { GOT_ERR_STAGED_PATHS, "work tree contains files with staged "
289 "changes; these changes must be committed or unstaged first" },
290 { GOT_ERR_PATCH_CHOICE, "invalid patch choice" },
291 { GOT_ERR_COMMIT_NO_EMAIL,"GOT_AUTHOR environment variable contains "
292 "no email address; an email address is required for compatibility "
293 "with Git" },
294 { GOT_ERR_TAG_EXISTS,"specified tag already exists" },
295 { GOT_ERR_GIT_REPO_FORMAT,"unknown git repository format version" },
296 { GOT_ERR_REBASE_REQUIRED,"specified branch must be rebased first" },
297 { GOT_ERR_REGEX, "regular expression error" },
298 { GOT_ERR_REF_NAME_MINUS, "reference name may not start with '-'" },
299 { GOT_ERR_GITCONFIG_SYNTAX, "gitconfig syntax error" },
300 { GOT_ERR_REBASE_OUT_OF_DATE, "work tree must be updated before it "
301 "can be used to rebase a branch" },
302 { GOT_ERR_CACHE_DUP_ENTRY, "duplicate cache entry" },
303 { GOT_ERR_QUERYSTRING, "bad querystring" },
304 { GOT_ERR_FETCH_FAILED, "fetch failed" },
305 { GOT_ERR_PARSE_URI, "failed to parse uri" },
306 { GOT_ERR_BAD_PROTO, "unknown protocol" },
307 { GOT_ERR_ADDRINFO, "getaddrinfo failed" },
308 { GOT_ERR_BAD_PACKET, "bad packet received" },
309 { GOT_ERR_NO_REMOTE, "remote repository not found" },
310 { GOT_ERR_FETCH_NO_BRANCH, "could not find any branches to fetch" },
311 { GOT_ERR_FETCH_BAD_REF, "reference cannot be fetched" },
312 { GOT_ERR_TREE_ENTRY_TYPE, "unexpected tree entry type" },
313 { GOT_ERR_PARSE_CONFIG, "configuration file syntax error" },
314 { GOT_ERR_NO_CONFIG_FILE, "configuration file doesn't exit" },
315 { GOT_ERR_BAD_SYMLINK, "symbolic link points outside of paths under "
316 "version control" },
317 { GOT_ERR_GIT_REPO_EXT, "unsupported repository format extension" },
318 { GOT_ERR_CANNOT_PACK, "not enough objects to pack" },
319 { GOT_ERR_LONELY_PACKIDX, "pack index has no corresponding pack file; "
320 "pack file must be restored or 'gotadmin cleanup -p' must be run" },
321 { GOT_ERR_OBJ_CSUM, "bad object checksum" },
322 { GOT_ERR_SEND_BAD_REF, "reference cannot be sent" },
323 { GOT_ERR_SEND_FAILED, "could not send pack file" },
324 { GOT_ERR_SEND_EMPTY, "no references to send" },
325 { GOT_ERR_SEND_ANCESTRY, "fetch and rebase required" },
326 { GOT_ERR_CAPA_DELETE_REFS, "server cannot delete references" },
327 { GOT_ERR_SEND_DELETE_REF, "reference cannot be deleted" },
328 { GOT_ERR_SEND_TAG_EXISTS, "tag already exists on server" },
329 { GOT_ERR_NOT_MERGING, "merge operation not in progress" },
330 { GOT_ERR_MERGE_OUT_OF_DATE, "work tree must be updated before it "
331 "can be used to merge a branch" },
332 { GOT_ERR_MERGE_STAGED_PATHS, "work tree contains files with staged "
333 "changes; these changes must be unstaged before merging can "
334 "proceed" },
335 { GOT_ERR_MERGE_COMMIT_OUT_OF_DATE, "merging cannot proceed because "
336 "the work tree is no longer up-to-date; merge must be aborted "
337 "and retried" },
338 { GOT_ERR_MERGE_BUSY,"a merge operation is in progress in this "
339 "work tree and must be continued or aborted first" },
340 { GOT_ERR_MERGE_PATH, "cannot merge branch which contains "
341 "changes outside of this work tree's path prefix" },
342 };
344 /*
345 * Get an error object from the above list, for a given error code.
346 * The error message is fixed.
347 */
348 const struct got_error *got_error(int);
350 /*
351 * Get an error object from the above list, for a given error code.
352 * Use the specified error message instead of the default one.
353 * Caution: If the message buffer lives in dynamically allocated memory,
354 * then this memory likely won't be freed.
355 */
356 const struct got_error *got_error_msg(int, const char *);
358 /*
359 * Get a statically allocated error object with code GOT_ERR_ERRNO
360 * and an error message obtained from strerror(3), prefixed with a
361 * string.
362 */
363 const struct got_error *got_error_from_errno(const char *);
365 /*
366 * Get a statically allocated error object with code GOT_ERR_ERRNO
367 * and an error message obtained from strerror(3), prefixed with two
368 * strings.
369 */
370 const struct got_error *got_error_from_errno2(const char *, const char *);
372 /*
373 * Get a statically allocated error object with code GOT_ERR_ERRNO
374 * and an error message obtained from strerror(3), prefixed with three
375 * strings.
376 */
377 const struct got_error *got_error_from_errno3(const char *, const char *,
378 const char *);
380 /*
381 * Get a statically allocated error object with code GOT_ERR_ERRNO
382 * and an error message obtained from strerror(3), prefixed with a
383 * string built with vsnprintf(3) from the provided format string
384 * and the variable-length list of additional arguments.
385 */
386 const struct got_error *got_error_from_errno_fmt(const char *, ...);
388 /*
389 * Set errno to the specified error code and return a statically
390 * allocated error object with code GOT_ERR_ERRNO and an error
391 * message obtained from strerror(3), optionally prefixed with a
392 * string.
393 */
394 const struct got_error *got_error_set_errno(int, const char *);
396 /*
397 * If ferror(3) indicates an error status for the FILE, obtain an error
398 * from got_error_from_errno(). Else, obtain the error via got_error()
399 * with the error code provided in the second argument.
400 */
401 const struct got_error *got_ferror(FILE *, int);
403 /*
404 * Obtain an error with code GOT_ERR_NO_OBJ and an error message which
405 * contains the specified object ID. The message buffer is statically
406 * allocated; future invocations of this function will overwrite the
407 * message set during earlier invocations.
408 */
409 struct got_object_id; /* forward declaration */
410 const struct got_error *got_error_no_obj(struct got_object_id *);
412 /*
413 * Obtain an error with code GOT_ERR_NOT_REF and an error message which
414 * contains the specified reference name. The message buffer is statically
415 * allocated; future invocations of this function will overwrite the
416 * message set during earlier invocations.
417 */
418 const struct got_error *got_error_not_ref(const char *);
420 /* Return an error based on a uuid(3) status code. */
421 const struct got_error *got_error_uuid(uint32_t, const char *);
423 /* Return an error with a path prefixed to the error message. */
424 const struct got_error *got_error_path(const char *, int);
426 /*
427 * Return an error with an error message prefix built by vsnprintf(3)
428 * from the provided format string and the variable-length list of
429 * additional arguments.
430 */
431 const struct got_error *got_error_fmt(int, const char *, ...);