From: Sebastian Harl Date: Thu, 23 Jan 2014 08:12:47 +0000 (+0100) Subject: client, sysdb: Improved error reporting. X-Git-Tag: sysdb-0.1.0~236 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=d81ce0f57da8db0d0e5fe74c29d112a81a5f068b;p=sysdb.git client, sysdb: Improved error reporting. --- diff --git a/src/client/sock.c b/src/client/sock.c index a2417ad..c722add 100644 --- a/src/client/sock.c +++ b/src/client/sock.c @@ -222,14 +222,14 @@ sdb_client_recv(sdb_client_t *client, size_t data_offset = sdb_strbuf_len(buf); + if (code) + *code = UINT32_MAX; + if ((! client) || (! client->fd) || (! buf)) { errno = EBADF; return -1; } - if (code) - *code = UINT32_MAX; - while (42) { ssize_t status; diff --git a/src/tools/sysdb/command.c b/src/tools/sysdb/command.c index 30e6419..f948d3a 100644 --- a/src/tools/sysdb/command.c +++ b/src/tools/sysdb/command.c @@ -33,8 +33,11 @@ #include "tools/sysdb/input.h" #include "frontend/proto.h" +#include "utils/error.h" #include "utils/strbuf.h" +#include + #include #include #include @@ -66,6 +69,7 @@ sdb_command_exec(sdb_input_t *input) if (query_len) { sdb_strbuf_t *recv_buf; + const char *result; uint32_t rcode = 0; recv_buf = sdb_strbuf_create(1024); @@ -81,7 +85,13 @@ sdb_command_exec(sdb_input_t *input) if (rcode == UINT32_MAX) printf("ERROR: "); - printf("%s\n", sdb_strbuf_string(recv_buf)); + result = sdb_strbuf_string(recv_buf); + if (result && *result) + printf("%s\n", result); + else if (rcode == UINT32_MAX) { + char errbuf[1024]; + printf("%s\n", sdb_strerror(errno, errbuf, sizeof(errbuf))); + } sdb_strbuf_destroy(recv_buf); }