Skip to content

Commit 61457fd

Browse files
JkLondonJkLondon
andauthored
Add specific error handling and message for MDBX_MAP_FULL scenario. (#160)
* Add specific error handling and message for MDBX_MAP_FULL scenario. * Clarify and expand the MapFullErrorRecommendation message for better guidance. * Simplify MapFull error message and update variable name accordingly. --------- Co-authored-by: JkLondon <ilya@mikheev.fun>
1 parent c6c6c6e commit 61457fd

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

mdbx/error.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,19 @@ var CorruptErrorHardwareRecommendations = "Maybe free space is over on disk. Oth
8484
var CorruptErrorBacktraceRecommendations = "Otherwise - please create issue in Application repo." // with backtrace or coredump. To create coredump set compile option 'MDBX_FORCE_ASSERTIONS=1' and env variable 'GOTRACEBACK=crash'."
8585
var CorruptErrorRecoveryRecommendations = "On default DURABLE mode, power outage can't cause this error. On other modes - power outage may break last transaction and mdbx_chk can recover db in this case, see '-t' and '-0|1|2' options."
8686
var CorruptErrorMessage = CorruptErrorHardwareRecommendations + " " + CorruptErrorBacktraceRecommendations + " " + CorruptErrorRecoveryRecommendations
87+
var MapFullErrorMessage = "The allocated database storage size limit has been reached."
8788

8889
func (e Errno) Error() string {
89-
if e == Corrupted {
90+
switch e {
91+
case Corrupted:
9092
return fmt.Sprintf("MDBX_FATAL(%d): ", int(e)) + CorruptErrorMessage
91-
}
92-
if e == Panic {
93+
case Panic:
9394
return fmt.Sprintf("MDBX_PANIC(%d): ", int(e)) + CorruptErrorMessage
95+
case MapFull:
96+
return fmt.Sprintf("MDBX_MAP_FULL(%d)", int(e)) + MapFullErrorMessage
97+
default:
98+
return C.GoString(C.mdbx_strerror(C.int(e)))
9499
}
95-
return C.GoString(C.mdbx_strerror(C.int(e)))
96100
}
97101

98102
// _operrno is for use by tests that can't import C

0 commit comments

Comments
 (0)