Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardize success/failure #174

Open
qpfiffer opened this issue Jul 14, 2015 · 0 comments
Open

Standardize success/failure #174

qpfiffer opened this issue Jul 14, 2015 · 0 comments

Comments

@qpfiffer
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant