diff options
author | Pieter Noordhuis <pcnoordhuis@gmail.com> | 2010-11-22 18:03:35 +0100 |
---|---|---|
committer | Pieter Noordhuis <pcnoordhuis@gmail.com> | 2010-11-22 18:03:35 +0100 |
commit | 808e43e16179d971fb7faaf5b79588f6abd0689c (patch) | |
tree | f3ce02289baf84df2af3be460fb6258ba41f46dc | |
parent | 56bbeb7049773f6210fc5173e2973dd292d3827f (diff) |
Update README with new way of handling errors
-rw-r--r-- | README.md | 17 |
1 files changed, 9 insertions, 8 deletions
@@ -35,16 +35,17 @@ To consume the synchronous API, there are only a few function calls that need to ### Connecting -The function `redisConnect` is used to create a so-called `redisContext`. The context is where -Hiredis holds state for a connection. The `redisContext` struct has an `error` field that is -non-NULL when the connection is in an error state. It contains a string with a textual -representation of the error. After trying to connect to Redis using `redisConnect` you should -check the `error` field to see if establishing the connection was successful: +The function `redisConnect` is used to create a so-called `redisContext`. The +context is where Hiredis holds state for a connection. The `redisContext` +struct has an integer `err` field that is non-zero when an the connection is in +an error state. The field `errstr` will contain a string with a description of +the error. After trying to connect to Redis using `redisConnect` you should +check the `err` field to see if establishing the connection was successful: redisContext *c = redisConnect("127.0.0.1", 6379); - if (c->error != NULL) { - printf("Error: %s\n", c->error); - // handle error + if (c->err) { + printf("Error: %s\n", c->errstr); + // handle error } ### Sending commands |