@@ -182,20 +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- super (CoreException , self ).__init__ ("%d (%s) - %s" % (code , self .codes [code ], self .message ))
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 ))
186187
187188
188- class NotFoundException (CoreException ):
189+ class NotFoundException (Exception ):
189190 pass
190191
191192
192193# assert the the returned obx_err is empty
193- def check_obx_err (code : obx_err , func , args ):
194+ def check_obx_err (code : obx_err , func , args ) -> obx_err :
194195 if code == 404 :
195- raise NotFoundException (code )
196+ raise NotFoundException ()
196197 elif code != 0 :
197198 raise CoreException (code )
198199
200+ return code
201+
199202
200203# assert that the returned pointer/int is non-empty
201204def check_result (result , func , args ):
@@ -208,13 +211,15 @@ def check_result(result, func, args):
208211def fn (name : str , restype : type , argtypes ):
209212 func = C .__getattr__ (name )
210213
214+ func .argtypes = argtypes
215+ func .restype = restype
216+
211217 if restype is obx_err :
212218 func .errcheck = check_obx_err
219+ pass
213220 elif restype is not None :
214221 func .errcheck = check_result
215- func .restype = restype
216222
217- func .argtypes = argtypes
218223 return func
219224
220225
@@ -250,13 +255,13 @@ def c_voidp_as_bytes(voidp, size):
250255obx_model_property_flags = fn ('obx_model_property_flags' , obx_err , [OBX_model_p , OBXPropertyFlags ])
251256
252257# obx_err (OBX_model*, obx_schema_id entity_id, obx_uid entity_uid);
253- 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 ])
254259
255260# obx_err (OBX_model* model, obx_schema_id index_id, obx_uid index_uid);
256- 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 ])
257262
258263# obx_err (OBX_model* model, obx_schema_id relation_id, obx_uid relation_uid);
259- 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 ])
260265
261266# obx_err (OBX_model* model, obx_schema_id property_id, obx_uid property_uid);
262267obx_model_entity_last_property_id = fn ('obx_model_entity_last_property_id' , obx_err ,
0 commit comments