Skip to content

Conversation

@bjosv
Copy link
Collaborator

@bjosv bjosv commented May 20, 2025

Add accessor functions to get the error status and string from contexts.
These functions replaces any direct access to err and errstr, and is a preparation for making contexts opaque.

Proposed naming:

/* Blocking API context */
int valkeyGetError(const valkeyContext *c);
const char *valkeyGetErrorString(const valkeyContext *c);

/* Async API context */
int valkeyAsyncGetError(const valkeyAsyncContext *ac);
const char *valkeyAsyncGetErrorString(const valkeyAsyncContext *ac);

/* Blocking Cluster API context */
int valkeyClusterGetError(const valkeyClusterContext *cc);
const char *valkeyClusterGetErrorString(const valkeyClusterContext *cc);

/* Async Cluster API context */
int valkeyClusterAsyncGetError(const valkeyClusterAsyncContext *acc);
const char *valkeyClusterAsyncGetErrorString(const valkeyClusterAsyncContext *acc);

Examples and tests have been updated, but READMEs needs to be updated too.

bjosv added 6 commits May 20, 2025 23:21
Signed-off-by: Björn Svensson <[email protected]>
git ls-files examples/cluster* | xargs sed -i 's|acc->errstr|valkeyClusterAsyncGetErrorString(acc)|g'
git ls-files examples/cluster* | xargs sed -i 's|acc->err|valkeyClusterAsyncGetError(acc)|g'
git ls-files examples/cluster* | xargs sed -i 's|cc->errstr|valkeyClusterGetErrorString(cc)|g'
git ls-files examples/cluster* | xargs sed -i 's|cc->err|valkeyClusterGetError(cc)|g'

git ls-files examples/async* | xargs sed -i 's|ac->errstr|valkeyAsyncGetErrorString(ac)|g'
git ls-files examples/async* | xargs sed -i 's|ac->err|valkeyAsyncGetError(ac)|g'
git ls-files examples/async* | xargs sed -i 's|c->errstr|valkeyAsyncGetErrorString(c)|g'
git ls-files examples/async* | xargs sed -i 's|c->err|valkeyAsyncGetError(c)|g'

git ls-files examples | xargs sed -i 's|ac->errstr|valkeyAsyncGetErrorString(ac)|g'
git ls-files examples | xargs sed -i 's|ac->err|valkeyAsyncGetError(ac)|g'
git ls-files examples | xargs sed -i 's|c->errstr|valkeyGetErrorString(c)|g'
git ls-files examples | xargs sed -i 's|c->err|valkeyGetError(c)|g'

Signed-off-by: Björn Svensson <[email protected]>
@bjosv bjosv requested a review from michael-grunder May 21, 2025 07:22
@bjosv
Copy link
Collaborator Author

bjosv commented May 21, 2025

The following naming variant has also been mentioned in issues/discussions:

int valkeyContextGetErr(const valkeyContext *c);
const char *valkeyContextGetErrStr(const valkeyContext *c);

Copy link
Collaborator

@michael-grunder michael-grunder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me. I think the naming is good too. Probably not worth saving a few characters going to Err.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants