Han-Wen Nienhuys | 8900447 | 2021-10-07 20:24:59 +0000 | [diff] [blame] | 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 | /* |
| 13 | * Errors in reftable calls are signaled with negative integer return values. 0 |
| 14 | * means success. |
| 15 | */ |
| 16 | enum reftable_error { |
| 17 | /* Unexpected file system behavior */ |
| 18 | REFTABLE_IO_ERROR = -2, |
| 19 | |
| 20 | /* Format inconsistency on reading data */ |
| 21 | REFTABLE_FORMAT_ERROR = -3, |
| 22 | |
| 23 | /* File does not exist. Returned from block_source_from_file(), because |
| 24 | * it needs special handling in stack. |
| 25 | */ |
| 26 | REFTABLE_NOT_EXIST_ERROR = -4, |
| 27 | |
Patrick Steinhardt | af18098 | 2024-03-25 11:02:42 +0100 | [diff] [blame] | 28 | /* Trying to access locked data. */ |
Han-Wen Nienhuys | 8900447 | 2021-10-07 20:24:59 +0000 | [diff] [blame] | 29 | REFTABLE_LOCK_ERROR = -5, |
| 30 | |
| 31 | /* Misuse of the API: |
| 32 | * - on writing a record with NULL refname. |
| 33 | * - on writing a reftable_ref_record outside the table limits |
| 34 | * - on writing a ref or log record before the stack's |
| 35 | * next_update_inde*x |
| 36 | * - on writing a log record with multiline message with |
| 37 | * exact_log_message unset |
| 38 | * - on reading a reftable_ref_record from log iterator, or vice versa. |
| 39 | * |
| 40 | * When a call misuses the API, the internal state of the library is |
| 41 | * kept unchanged. |
| 42 | */ |
| 43 | REFTABLE_API_ERROR = -6, |
| 44 | |
| 45 | /* Decompression error */ |
| 46 | REFTABLE_ZLIB_ERROR = -7, |
| 47 | |
| 48 | /* Wrote a table without blocks. */ |
| 49 | REFTABLE_EMPTY_TABLE_ERROR = -8, |
| 50 | |
Han-Wen Nienhuys | 8900447 | 2021-10-07 20:24:59 +0000 | [diff] [blame] | 51 | /* Invalid ref name. */ |
| 52 | REFTABLE_REFNAME_ERROR = -10, |
Han-Wen Nienhuys | 0dd4458 | 2021-12-23 19:29:49 +0000 | [diff] [blame] | 53 | |
| 54 | /* Entry does not fit. This can happen when writing outsize reflog |
| 55 | messages. */ |
| 56 | REFTABLE_ENTRY_TOO_BIG_ERROR = -11, |
Patrick Steinhardt | af18098 | 2024-03-25 11:02:42 +0100 | [diff] [blame] | 57 | |
| 58 | /* Trying to write out-of-date data. */ |
| 59 | REFTABLE_OUTDATED_ERROR = -12, |
Han-Wen Nienhuys | 8900447 | 2021-10-07 20:24:59 +0000 | [diff] [blame] | 60 | }; |
| 61 | |
| 62 | /* convert the numeric error code to a string. The string should not be |
| 63 | * deallocated. */ |
| 64 | const char *reftable_error_str(int err); |
| 65 | |
| 66 | #endif |