-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Labels
Description
We have too many obtuse return codes for various functions. Add an enum thats something like OLEG_SUCCESS and OLEG_FAILURE. Have all ol_* and olt_* functions return them.
Then, when this is done, fix the stupid error handling in all of the ol_* wrapper functions. I'm talking about this:
int ol_jar(ol_database *db, const char *key, size_t klen,
const unsigned char *value, size_t vsize) {
/* ... Stuff omitted ... */
ol_transaction *tx = olt_begin(db);
int jar_ret = 10;
check(tx != NULL, "Could not begin implicit transaction.");
jar_ret = olt_jar(tx, key, klen, value, vsize);
check(jar_ret == 0, "Could not jar value. Aborting.");
check(olt_commit(tx) == 0, "Could not commit transaction.");
return jar_ret;
error:
if (tx != NULL && jar_ret != 10)
olt_abort(tx);
return jar_ret;
}Something that'd be pretty cool here is to return SUCCESS/FAILURE, but in addition modify an internal variable to set what happened so we can still get access to some error granularity. This is an sqlite style thing which I really like. This would entail adding some kind of ol_error(const ol_database *db, char *out_ptr) function to return a set of standardized error codes.