Skip to content

Commit 527e061

Browse files
committed
Base exception shall be named DbError #64
1 parent decab4c commit 527e061

File tree

7 files changed

+126
-133
lines changed

7 files changed

+126
-133
lines changed

objectbox/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from objectbox.model.properties import Id, String, Index, Bool, Int8, Int16, Int32, Int64, Float32, Float64, Bytes, BoolVector, Int8Vector, Int16Vector, Int32Vector, Int64Vector, Float32Vector, Float64Vector, CharVector, BoolList, Int8List, Int16List, Int32List, Int64List, Float32List, Float64List, CharList, Date, DateNano, Flex, HnswIndex, VectorDistanceType, HnswFlags
2121
from objectbox.model.model import Model
2222
from objectbox.c import version_core, DebugFlags
23-
from objectbox.exceptions import StorageException
23+
from objectbox.exceptions import DbError
2424
from objectbox.version import Version
2525
from objectbox.condition import PropertyQueryCondition
2626
from objectbox.query import Query
@@ -67,7 +67,7 @@
6767
'VectorDistanceType',
6868
'Store',
6969
'ObjectBox',
70-
'StorageException',
70+
'DbError',
7171
'version',
7272
'version_info',
7373
'DebugFlags',

objectbox/box.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from objectbox.query_builder import QueryBuilder
1919
from objectbox.condition import QueryCondition
2020
from objectbox.c import *
21-
from objectbox.exceptions import StorageException
21+
from objectbox.exceptions import DbError
2222

2323

2424
class Box:
@@ -122,7 +122,7 @@ def get(self, id: int):
122122
if code == 404:
123123
return None
124124
elif code != 0:
125-
raise StorageException.from_code(code)
125+
raise DbError.from_code(code)
126126
data = c_voidp_as_bytes(c_data, c_size.value)
127127
return self._entity._unmarshal(data)
128128

@@ -157,7 +157,7 @@ def remove(self, id_or_object) -> bool:
157157
if code == 404:
158158
return False
159159
elif code != 0:
160-
raise StorageException.from_code(code)
160+
raise DbError.from_code(code)
161161
return True
162162

163163
def remove_all(self) -> int:

objectbox/c.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ class OBX_query(ctypes.Structure):
256256
C.obx_last_error_code.restype = obx_err
257257

258258

259-
class StorageErrorCode(IntEnum):
259+
class DbErrorCode(IntEnum):
260260
OBX_SUCCESS = 0
261261
OBX_NOT_FOUND = 404
262262
OBX_NO_SUCCESS = 1001
@@ -305,25 +305,25 @@ class StorageErrorCode(IntEnum):
305305

306306
def check_obx_err(code: obx_err, func, args) -> obx_err:
307307
""" Raises an exception if obx_err is not successful. """
308-
if code != StorageErrorCode.OBX_SUCCESS:
309-
from objectbox.exceptions import create_storage_exception
310-
raise create_storage_exception(code)
308+
if code != DbErrorCode.OBX_SUCCESS:
309+
from objectbox.exceptions import create_db_error
310+
raise create_db_error(code)
311311
return code
312312

313313

314314
def check_obx_qb_cond(qb_cond: obx_qb_cond, func, args) -> obx_qb_cond:
315315
""" Raises an exception if obx_qb_cond is not successful. """
316316
if qb_cond == 0:
317-
from objectbox.exceptions import create_storage_exception
318-
raise create_storage_exception(C.obx_last_error_code())
317+
from objectbox.exceptions import create_db_error
318+
raise create_db_error(C.obx_last_error_code())
319319
return qb_cond
320320

321321

322322
# assert that the returned pointer/int is non-empty
323323
def check_result(result, func, args):
324324
if not result:
325-
from objectbox.exceptions import create_storage_exception
326-
raise create_storage_exception(C.obx_last_error_code())
325+
from objectbox.exceptions import create_db_error
326+
raise create_db_error(C.obx_last_error_code())
327327
return result
328328

329329

0 commit comments

Comments
 (0)