Raw
1 /*
2 * Copyright 2020 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style
5 * license that can be found in the LICENSE file or at
6 * https://developers.google.com/open-source/licenses/bsd
7 */
8
9 #ifndef REFTABLE_ERROR_H
10 #define REFTABLE_ERROR_H
11
12 #include "reftable-system.h"
13
14 /*
15 * Errors in reftable calls are signaled with negative integer return values. 0
16 * means success.
17 */
18 enum reftable_error {
19 /* Unexpected file system behavior */
20 REFTABLE_IO_ERROR = -2,
21
22 /* Format inconsistency on reading data */
23 REFTABLE_FORMAT_ERROR = -3,
24
25 /* File does not exist. Returned from block_source_from_file(), because
26 * it needs special handling in stack.
27 */
28 REFTABLE_NOT_EXIST_ERROR = -4,
29
30 /* Trying to access locked data. */
31 REFTABLE_LOCK_ERROR = -5,
32
33 /* Misuse of the API:
34 * - on writing a record with NULL refname.
35 * - on writing a record before setting the writer limits.
36 * - on writing a reftable_ref_record outside the table limits
37 * - on writing a ref or log record before the stack's
38 * next_update_inde*x
39 * - on writing a log record with multiline message with
40 * exact_log_message unset
41 * - on reading a reftable_ref_record from log iterator, or vice versa.
42 *
43 * When a call misuses the API, the internal state of the library is
44 * kept unchanged.
45 */
46 REFTABLE_API_ERROR = -6,
47
48 /* Decompression error */
49 REFTABLE_ZLIB_ERROR = -7,
50
51 /* Wrote a table without blocks. */
52 REFTABLE_EMPTY_TABLE_ERROR = -8,
53
54 /* Invalid ref name. */
55 REFTABLE_REFNAME_ERROR = -10,
56
57 /* Entry does not fit. This can happen when writing outsize reflog
58 messages. */
59 REFTABLE_ENTRY_TOO_BIG_ERROR = -11,
60
61 /* Trying to write out-of-date data. */
62 REFTABLE_OUTDATED_ERROR = -12,
63
64 /* An allocation has failed due to an out-of-memory situation. */
65 REFTABLE_OUT_OF_MEMORY_ERROR = -13,
66 };
67
68 /* convert the numeric error code to a string. The string should not be
69 * deallocated. */
70 const char *reftable_error_str(int err);
71
72 #endif