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