Selaa lähdekoodia

Throw specific error for invalid transactions.

Stefano Cossu 5 vuotta sitten
vanhempi
commit
3e18c42e60
1 muutettua tiedostoa jossa 9 lisäystä ja 0 poistoa
  1. 9 0
      lakesuperior/store/base_lmdb_store.pyx

+ 9 - 0
lakesuperior/store/base_lmdb_store.pyx

@@ -27,6 +27,12 @@ cdef void _check(int rc, str message='') except *:
         raise KeyNotFoundError()
     if rc == lmdb.MDB_KEYEXIST:
         raise KeyExistsError()
+    if rc == errno.EINVAL:
+        raise InvalidParamError(
+            'Invalid LMDB parameter error.\n'
+            'Please verify that a transaction is open and valid for the '
+            'current operation.'
+        )
     if rc != lmdb.MDB_SUCCESS:
         out_msg = (
                 message + '\nInternal error ({}): '.format(rc)
@@ -44,6 +50,9 @@ class KeyNotFoundError(LmdbError):
 class KeyExistsError(LmdbError):
     pass
 
+class InvalidParamError(LmdbError):
+    pass
+
 
 
 cdef class BaseLmdbStore: