Skip to content

Commit dd37032

Browse files
author
Ivan Dlugos
committed
update c.model_last_* definitions
1 parent 496d8b9 commit dd37032

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

objectbox/c.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -182,24 +182,23 @@ class CoreException(Exception):
182182
def __init__(self, code):
183183
self.code = code
184184
self.message = py_str(C.obx_last_error_message())
185-
if code in self.codes:
186-
text = "%d (%s) - %s" % (code, self.codes[code], self.message)
187-
else:
188-
text = "%d - %s" % (code, self.message)
189-
super(CoreException, self).__init__(text)
185+
name = self.codes[code] if code in self.codes else "n/a"
186+
super(CoreException, self).__init__("%d (%s) - %s" % (code, name, self.message))
190187

191188

192-
class NotFoundException(CoreException):
189+
class NotFoundException(Exception):
193190
pass
194191

195192

196193
# assert the the returned obx_err is empty
197-
def check_obx_err(code: obx_err, func, args):
194+
def check_obx_err(code: obx_err, func, args) -> obx_err:
198195
if code == 404:
199-
raise NotFoundException(code)
196+
raise NotFoundException()
200197
elif code != 0:
201198
raise CoreException(code)
202199

200+
return code
201+
203202

204203
# assert that the returned pointer/int is non-empty
205204
def check_result(result, func, args):
@@ -217,6 +216,7 @@ def fn(name: str, restype: type, argtypes):
217216

218217
if restype is obx_err:
219218
func.errcheck = check_obx_err
219+
pass
220220
elif restype is not None:
221221
func.errcheck = check_result
222222

@@ -255,13 +255,13 @@ def c_voidp_as_bytes(voidp, size):
255255
obx_model_property_flags = fn('obx_model_property_flags', obx_err, [OBX_model_p, OBXPropertyFlags])
256256

257257
# obx_err (OBX_model*, obx_schema_id entity_id, obx_uid entity_uid);
258-
obx_model_last_entity_id = fn('obx_model_last_entity_id', obx_err, [OBX_model_p, obx_schema_id, obx_uid])
258+
obx_model_last_entity_id = fn('obx_model_last_entity_id', None, [OBX_model_p, obx_schema_id, obx_uid])
259259

260260
# obx_err (OBX_model* model, obx_schema_id index_id, obx_uid index_uid);
261-
obx_model_last_index_id = fn('obx_model_last_index_id', obx_err, [OBX_model_p, obx_schema_id, obx_uid])
261+
obx_model_last_index_id = fn('obx_model_last_index_id', None, [OBX_model_p, obx_schema_id, obx_uid])
262262

263263
# obx_err (OBX_model* model, obx_schema_id relation_id, obx_uid relation_uid);
264-
obx_model_last_relation_id = fn('obx_model_last_relation_id', obx_err, [OBX_model_p, obx_schema_id, obx_uid])
264+
obx_model_last_relation_id = fn('obx_model_last_relation_id', None, [OBX_model_p, obx_schema_id, obx_uid])
265265

266266
# obx_err (OBX_model* model, obx_schema_id property_id, obx_uid property_uid);
267267
obx_model_entity_last_property_id = fn('obx_model_entity_last_property_id', obx_err,

0 commit comments

Comments
 (0)