forked from lmdbjava/lmdbjava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLmdbNativeException.java
More file actions
135 lines (110 loc) · 3.5 KB
/
Copy pathLmdbNativeException.java
File metadata and controls
135 lines (110 loc) · 3.5 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
/*-
* #%L
* LmdbJava
* %%
* Copyright (C) 2016 - 2018 The LmdbJava Open Source Project
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package org.lmdbjava;
import static java.lang.String.format;
/**
* Superclass for all exceptions that originate from a native C call.
*/
public class LmdbNativeException extends LmdbException {
private static final long serialVersionUID = 1L;
/**
* Result code returned by the LMDB C function.
*/
private final int rc;
/**
* Constructs an instance with the provided detailed message.
*
* @param msg the detail message.
* @param rc the result code.
*/
LmdbNativeException(final int rc, final String msg) {
super(format(msg + " (%d)", rc));
this.rc = rc;
}
/**
* Obtain the LMDB C-side result code.
*
* @return the C-side result code
*/
public final int getResultCode() {
return rc;
}
/**
* Exception raised from a system constant table lookup.
*/
public static final class ConstantDerviedException extends LmdbNativeException {
private static final long serialVersionUID = 1L;
ConstantDerviedException(final int rc, final String message) {
super(rc, "Platform constant error code: " + message);
}
}
/**
* Located page was wrong type.
*/
public static final class PageCorruptedException extends LmdbNativeException {
static final int MDB_CORRUPTED = -30_796;
private static final long serialVersionUID = 1L;
PageCorruptedException() {
super(MDB_CORRUPTED, "located page was wrong type");
}
}
/**
* Page has not enough space - internal error.
*/
public static final class PageFullException extends LmdbNativeException {
static final int MDB_PAGE_FULL = -30_786;
private static final long serialVersionUID = 1L;
PageFullException() {
super(MDB_PAGE_FULL, "Page has not enough space - internal error");
}
}
/**
* Requested page not found - this usually indicates corruption.
*/
public static final class PageNotFoundException extends LmdbNativeException {
static final int MDB_PAGE_NOTFOUND = -30_797;
private static final long serialVersionUID = 1L;
PageNotFoundException() {
super(MDB_PAGE_NOTFOUND,
"Requested page not found - this usually indicates corruption");
}
}
/**
* Update of meta page failed or environment had fatal error.
*/
public static final class PanicException extends LmdbNativeException {
static final int MDB_PANIC = -30_795;
private static final long serialVersionUID = 1L;
PanicException() {
super(MDB_PANIC,
"Update of meta page failed or environment had fatal error");
}
}
/**
* Too many TLS keys in use - Windows only.
*/
public static final class TlsFullException extends LmdbNativeException {
static final int MDB_TLS_FULL = -30_789;
private static final long serialVersionUID = 1L;
TlsFullException() {
super(MDB_TLS_FULL, "Too many TLS keys in use - Windows only");
}
}
}