소스 검색

Throw specific error for invalid transactions.

Stefano Cossu 5 년 전
부모
커밋
3e18c42e60
1개의 변경된 파일9개의 추가작업 그리고 0개의 파일을 삭제
  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: