1/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 *     Copyright 2010 Couchbase, Inc
4 *
5 *   Licensed under the Apache License, Version 2.0 (the "License");
6 *   you may not use this file except in compliance with the License.
7 *   You may obtain a copy of the License at
8 *
9 *       http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *   Unless required by applicable law or agreed to in writing, software
12 *   distributed under the License is distributed on an "AS IS" BASIS,
13 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *   See the License for the specific language governing permissions and
15 *   limitations under the License.
16 */
17
18#ifndef _FDB_ERRORS_H
19#define _FDB_ERRORS_H
20
21#include <stdint.h>
22#include <stddef.h>
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28/**
29 * Status values returned by calling ForestDB APIs.
30 */
31typedef enum {
32    /**
33     * ForestDB operation success.
34     */
35    FDB_RESULT_SUCCESS = 0,
36    /**
37     * Invalid parameters to ForestDB APIs.
38     */
39    FDB_RESULT_INVALID_ARGS = -1,
40    /**
41     * Database open operation fails.
42     */
43    FDB_RESULT_OPEN_FAIL = -2,
44    /**
45     * Database file not found.
46     */
47    FDB_RESULT_NO_SUCH_FILE = -3,
48    /**
49     * Database write operation fails.
50     */
51    FDB_RESULT_WRITE_FAIL = -4,
52    /**
53     * Database read operation fails.
54     */
55    FDB_RESULT_READ_FAIL = -5,
56    /**
57     * Database close operation fails.
58     */
59    FDB_RESULT_CLOSE_FAIL = -6,
60    /**
61     * Database commit operation fails.
62     */
63    FDB_RESULT_COMMIT_FAIL = -7,
64    /**
65     * Memory allocation fails.
66     */
67    FDB_RESULT_ALLOC_FAIL = -8,
68    /**
69     * A key not found in database.
70     */
71    FDB_RESULT_KEY_NOT_FOUND = -9,
72    /**
73     * Read-only access violation.
74     */
75    FDB_RESULT_RONLY_VIOLATION = -10,
76    /**
77     * Database compaction fails.
78     */
79    FDB_RESULT_COMPACTION_FAIL = -11,
80    /**
81     * Database iterator operation fails.
82     */
83    FDB_RESULT_ITERATOR_FAIL = -12,
84    /**
85     * ForestDB I/O seek failure.
86     */
87    FDB_RESULT_SEEK_FAIL = -13,
88    /**
89     * ForestDB I/O fsync failure.
90     */
91    FDB_RESULT_FSYNC_FAIL = -14,
92    /**
93     * ForestDB I/O checksum error.
94     */
95    FDB_RESULT_CHECKSUM_ERROR = -15,
96    /**
97     * ForestDB I/O file corruption.
98     */
99    FDB_RESULT_FILE_CORRUPTION = -16,
100    /**
101     * ForestDB I/O compression error.
102     */
103    FDB_RESULT_COMPRESSION_FAIL = -17,
104    /**
105     * A database instance with a given sequence number was not found.
106     */
107    FDB_RESULT_NO_DB_INSTANCE = -18,
108    /**
109     * Requested FDB operation failed as rollback is currently being executed.
110     */
111    FDB_RESULT_FAIL_BY_ROLLBACK = -19,
112    /**
113     * ForestDB config value is invalid.
114     */
115    FDB_RESULT_INVALID_CONFIG = -20,
116    /**
117     * Try to perform manual compaction when compaction daemon is enabled.
118     */
119    FDB_RESULT_MANUAL_COMPACTION_FAIL = -21,
120    /**
121     * Open a file with invalid compaction mode.
122     */
123    FDB_RESULT_INVALID_COMPACTION_MODE = -22,
124    /**
125     * Operation cannot be performed as file handle has not been closed.
126     */
127    FDB_RESULT_FILE_IS_BUSY = -23,
128    /**
129     * Database file remove operation fails.
130     */
131    FDB_RESULT_FILE_REMOVE_FAIL = -24,
132    /**
133     * Database file rename operation fails.
134     */
135    FDB_RESULT_FILE_RENAME_FAIL = -25,
136    /**
137     * Transaction operation fails.
138     */
139    FDB_RESULT_TRANSACTION_FAIL = -26,
140    /**
141     * Requested FDB operation failed due to active transactions.
142     */
143    FDB_RESULT_FAIL_BY_TRANSACTION = -27,
144    /**
145     * Requested FDB operation failed due to an active compaction task.
146     */
147    FDB_RESULT_FAIL_BY_COMPACTION = -28,
148    /**
149     * Filename is too long.
150     */
151    FDB_RESULT_TOO_LONG_FILENAME = -29,
152    /**
153     * Passed ForestDB handle is Invalid.
154     */
155    FDB_RESULT_INVALID_HANDLE = -30,
156    /**
157     * A KV store not found in database.
158     */
159    FDB_RESULT_KV_STORE_NOT_FOUND = -31,
160    /**
161     * There is an opened handle of the KV store.
162     */
163    FDB_RESULT_KV_STORE_BUSY = -32,
164    /**
165     * Same KV instance name already exists.
166     */
167    FDB_RESULT_INVALID_KV_INSTANCE_NAME = -33,
168    /**
169     * Custom compare function is assigned incorrectly.
170     */
171    FDB_RESULT_INVALID_CMP_FUNCTION = -34,
172    /**
173     * DB file can't be destroyed as the file is being compacted.
174     * Please retry in sometime.
175     */
176    FDB_RESULT_IN_USE_BY_COMPACTOR = -35,
177    /**
178     * DB file used in this operation has not been opened
179     */
180    FDB_RESULT_FILE_NOT_OPEN = -36,
181    /**
182     * Buffer cache is too big to be configured because it is greater than
183     * the physical memory available.
184     */
185    FDB_RESULT_TOO_BIG_BUFFER_CACHE = -37,
186    /**
187     * No commit headers in a database file.
188     */
189    FDB_RESULT_NO_DB_HEADERS = -38,
190    /**
191     * DB handle is being used by another thread. Forestdb handles must not be
192     * shared among multiple threads.
193     */
194    FDB_RESULT_HANDLE_BUSY = -39,
195    /**
196     * Asynchronous I/O is not supported in the current OS version.
197     */
198    FDB_RESULT_AIO_NOT_SUPPORTED = -40,
199    /**
200     * Asynchronous I/O init fails.
201     */
202    FDB_RESULT_AIO_INIT_FAIL = -41,
203    /**
204     * Asynchronous I/O submit fails.
205     */
206    FDB_RESULT_AIO_SUBMIT_FAIL = -42,
207    /**
208     * Fail to read asynchronous I/O events from the completion queue.
209     */
210    FDB_RESULT_AIO_GETEVENTS_FAIL = -43,
211    /**
212     * Error encrypting or decrypting data, or unsupported encryption algorithm.
213     */
214    FDB_RESULT_CRYPTO_ERROR = -44,
215    /**
216     * Compaction task is aborted due to compaction cancellation request
217     * from the application.
218     */
219    FDB_RESULT_COMPACTION_CANCELLATION = -45,
220
221    FDB_RESULT_LAST = FDB_RESULT_CRYPTO_ERROR // Last (minimum) fdb_status value
222} fdb_status;
223
224#ifdef __cplusplus
225}
226#endif
227
228#endif
229