-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy patherror.hpp
More file actions
260 lines (184 loc) · 4.88 KB
/
error.hpp
File metadata and controls
260 lines (184 loc) · 4.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
//
// Copyright (c) 2015-2016 Vinnie Falco (vinnie dot falco at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef NUDB_ERROR_HPP
#define NUDB_ERROR_HPP
#include <boost/system/system_error.hpp>
#include <boost/system/error_code.hpp>
namespace nudb {
/// The type of system-specific error code returned by the implementation
#if GENERATING_DOCS
class error_code{};
#else
using boost::system::error_code;
#endif
/// The type of cross-platform error code used by the implementation
#if GENERATING_DOCS
class error_condition{};
#else
using boost::system::error_condition;
#endif
/// The type of system-specific exception used when throwing
#if GENERATING_DOCS
class system_error{};
#else
using boost::system::system_error;
#endif
/// Returns the category used for system-specific error codes
#if GENERATING_DOCS
error_category const&
system_category();
#else
using boost::system::system_category;
#endif
/// Returns the category used for cross-platform error codes
#if GENERATING_DOCS
error_category const&
generic_category();
#else
using boost::system::generic_category;
#endif
/// The base class used for error categories
#if GENERATING_DOCS
class error_category{};
#else
using boost::system::error_category;
#endif
/// The set of constants used for cross-platform error codes
#if GENERATING_DOCS
enum errc{};
#else
namespace errc = boost::system::errc;
#endif
/// Database error codes.
enum class error
{
/** The specified key was not found.
Returned when @ref basic_store::fetch does not
find the specified key.
*/
key_not_found,
/** The specified key already exists.
Returned when @ref basic_store::insert finds
the specified key already in the database.
*/
key_exists,
/** A file read returned less data than expected.
This can be caused by premature application
termination during a commit cycle.
*/
short_read,
/** A log file is present.
Indicates that the database needs to have the
associated log file applied to perform a recovery.
This error is returned by functions such as @ref rekey.
*/
log_file_exists,
/** No key file exists.
This error is returned by the recover process when
there is no valid key file. It happens when a
@ref rekey operation prematurely terminates. A
database without a key file cannot be opened. To
fix this error, it is necessary for an invocation of
@ref rekey to complete successfully.
*/
no_key_file,
/// Too many buckets in key file
too_many_buckets,
/// Not a data file
not_data_file,
/// Not a key file
not_key_file,
/// Not a log file
not_log_file,
/// Different version
different_version,
/// Invalid key size
invalid_key_size,
/// Invalid block size
invalid_block_size,
/// Short key file
short_key_file,
/// Short bucket
short_bucket,
/// Short spill
short_spill,
/// Short record
short_data_record,
/// Short value
short_value,
/// Hash mismatch
hash_mismatch,
/// Invalid load factor
invalid_load_factor,
/// Invalid capacity
invalid_capacity,
/// Invalid bucket count
invalid_bucket_count,
/// Invalid bucket size
invalid_bucket_size,
/// The data file header was incomplete
incomplete_data_file_header,
/// The key file header was incomplete
incomplete_key_file_header,
/// Invalid log record
invalid_log_record,
/// Invalid spill in log record
invalid_log_spill,
/// Invalid offset in log record
invalid_log_offset,
/// Invalid index in log record
invalid_log_index,
/// Invalid size in spill
invalid_spill_size,
/// UID mismatch
uid_mismatch,
/// appnum mismatch
appnum_mismatch,
/// key size mismatch
key_size_mismatch,
/// salt mismatch
salt_mismatch,
/// pepper mismatch
pepper_mismatch,
/// block size mismatch
block_size_mismatch,
/// orphaned value
orphaned_value,
/// missing value
missing_value,
/// size mismatch
size_mismatch,
/// duplicate value
duplicate_value,
/// directory not found
dir_not_found
};
/// Returns the error category used for database error codes.
error_category const&
nudb_category();
/** Returns a database error code.
This function is used by the implementation to convert
@ref error values into @ref error_code objects.
*/
inline
error_code
make_error_code(error ev)
{
return error_code{static_cast<int>(ev), nudb_category()};
}
} // nudb
namespace boost {
namespace system {
template<>
struct is_error_code_enum<nudb::error>
{
static bool const value = true;
};
} // system
} // boost
#include <nudb/impl/error.ipp>
#endif