Electroneum
Toggle main menu visibility
Loading...
Searching...
No Matches
error.cpp
Go to the documentation of this file.
1
// Copyright (c) 2014-2018, The Monero Project
2
// All rights reserved.
3
//
4
// Redistribution and use in source and binary forms, with or without modification, are
5
// permitted provided that the following conditions are met:
6
//
7
// 1. Redistributions of source code must retain the above copyright notice, this list of
8
// conditions and the following disclaimer.
9
//
10
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
11
// of conditions and the following disclaimer in the documentation and/or other
12
// materials provided with the distribution.
13
//
14
// 3. Neither the name of the copyright holder nor the names of its contributors may be
15
// used to endorse or promote products derived from this software without specific
16
// prior written permission.
17
//
18
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
19
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
21
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
25
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
26
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28
#include "
error.h
"
29
30
#include <
lmdb.h
>
31
#include <string>
32
33
namespace
{
34
struct
category final : std::error_category
35
{
36
virtual
const
char
*
name
() const noexcept override final
37
{
38
return
"lmdb::error_category()"
;
39
}
40
41
virtual
std::string
message
(
int
value
)
const
override
final
42
{
43
char
const
*
const
msg =
mdb_strerror
(
value
);
44
if
(msg)
45
return
msg;
46
return
"Unknown lmdb::error_category() value"
;
47
}
48
49
virtual
std::error_condition default_error_condition(
int
value
)
const
noexcept
override
final
50
{
51
switch
(
value
)
52
{
53
case
MDB_KEYEXIST
:
54
case
MDB_NOTFOUND
:
55
break
;
// map to nothing generic
56
case
MDB_PAGE_NOTFOUND
:
57
case
MDB_CORRUPTED
:
58
return
std::errc::bad_address;
59
case
MDB_PANIC
:
60
case
MDB_VERSION_MISMATCH
:
61
case
MDB_INVALID
:
62
break
;
// map to nothing generic
63
case
MDB_MAP_FULL
:
64
return
std::errc::no_buffer_space;
65
case
MDB_DBS_FULL
:
66
break
;
// map to nothing generic
67
case
MDB_READERS_FULL
:
68
case
MDB_TLS_FULL
:
69
return
std::errc::no_lock_available;
70
case
MDB_TXN_FULL
:
71
case
MDB_CURSOR_FULL
:
72
case
MDB_PAGE_FULL
:
73
case
MDB_MAP_RESIZED
:
74
break
;
// map to nothing generic
75
case
MDB_INCOMPATIBLE
:
76
return
std::errc::invalid_argument;
77
case
MDB_BAD_RSLOT
:
78
case
MDB_BAD_TXN
:
79
case
MDB_BAD_VALSIZE
:
80
case
MDB_BAD_DBI
:
81
return
std::errc::invalid_argument;
82
default
:
83
return
std::error_condition{
value
, std::generic_category()};
84
}
85
return
std::error_condition{
value
, *
this
};
86
}
87
};
88
}
89
90
namespace
lmdb
91
{
92
std::error_category
const
&
error_category
() noexcept
93
{
94
static
const
category instance{};
95
return
instance;
96
}
97
}
98
message
std::string message("Message requiring signing")
MDB_PAGE_FULL
#define MDB_PAGE_FULL
Definition
lmdb.h:463
MDB_KEYEXIST
#define MDB_KEYEXIST
Definition
lmdb.h:437
MDB_MAP_FULL
#define MDB_MAP_FULL
Definition
lmdb.h:451
MDB_BAD_RSLOT
#define MDB_BAD_RSLOT
Definition
lmdb.h:476
MDB_BAD_VALSIZE
#define MDB_BAD_VALSIZE
Definition
lmdb.h:480
MDB_DBS_FULL
#define MDB_DBS_FULL
Definition
lmdb.h:453
MDB_MAP_RESIZED
#define MDB_MAP_RESIZED
Definition
lmdb.h:465
MDB_PAGE_NOTFOUND
#define MDB_PAGE_NOTFOUND
Definition
lmdb.h:441
MDB_VERSION_MISMATCH
#define MDB_VERSION_MISMATCH
Definition
lmdb.h:447
MDB_INVALID
#define MDB_INVALID
Definition
lmdb.h:449
MDB_INCOMPATIBLE
#define MDB_INCOMPATIBLE
Definition
lmdb.h:474
MDB_BAD_DBI
#define MDB_BAD_DBI
Definition
lmdb.h:482
MDB_TLS_FULL
#define MDB_TLS_FULL
Definition
lmdb.h:457
MDB_NOTFOUND
#define MDB_NOTFOUND
Definition
lmdb.h:439
MDB_TXN_FULL
#define MDB_TXN_FULL
Definition
lmdb.h:459
MDB_BAD_TXN
#define MDB_BAD_TXN
Definition
lmdb.h:478
MDB_READERS_FULL
#define MDB_READERS_FULL
Definition
lmdb.h:455
MDB_CURSOR_FULL
#define MDB_CURSOR_FULL
Definition
lmdb.h:461
MDB_PANIC
#define MDB_PANIC
Definition
lmdb.h:445
MDB_CORRUPTED
#define MDB_CORRUPTED
Definition
lmdb.h:443
mdb_strerror
char * mdb_strerror(int err)
Return a string describing a given error code.
lmdb.h
Lightning memory-mapped database library.
el::base::consts::name
const char * name
Definition
easylogging++.h:795
lmdb
Definition
database.cpp:46
lmdb::error_category
std::error_category const & error_category() noexcept
Definition
error.cpp:92
value
const GenericPointer< typename T::ValueType > T2 value
Definition
pointer.h:1225
error.h
src
lmdb
error.cpp
Generated on
for Electroneum by
1.17.0