diff options
author | James Booth <boothj5@gmail.com> | 2014-01-26 22:50:22 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2014-01-26 22:50:22 +0000 |
commit | 1a300ce7d35092b93814eac00008aae3d98819a1 (patch) | |
tree | 848bc131b23589def00b718bf1f903004fb31aa4 /src/xmpp | |
parent | 50f1a5ecc0686cf22fc2c9d5766a4954a24fe5d5 (diff) | |
download | profani-tty-1a300ce7d35092b93814eac00008aae3d98819a1.tar.gz |
Show original error message
Diffstat (limited to 'src/xmpp')
-rw-r--r-- | src/xmpp/message.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/xmpp/message.c b/src/xmpp/message.c index d814d59d..236999b9 100644 --- a/src/xmpp/message.c +++ b/src/xmpp/message.c @@ -194,15 +194,28 @@ _message_error_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * const userdata) { // log message, function never returns NULL - char *err_msg = stanza_get_error_message(stanza); char *id = xmpp_stanza_get_id(stanza); + char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); + char *err_msg = stanza_get_error_message(stanza); + + GString *log_msg = g_string_new("Error receievd"); if (id != NULL) { - log_info("Error recieved (id=%s): %s", id, err_msg); - } else { - log_info("Error received: %s", err_msg); + g_string_append(log_msg, " (id:"); + g_string_append(log_msg, id); + g_string_append(log_msg, ")"); + } + if (from != NULL) { + g_string_append(log_msg, " (from:"); + g_string_append(log_msg, from); + g_string_append(log_msg, ")"); } + g_string_append(log_msg, ", error: "); + g_string_append(log_msg, err_msg); + + log_info(log_msg->str); + + g_string_free(log_msg, TRUE); - char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); xmpp_stanza_t *error_stanza = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ERROR); char *type = NULL; if (error_stanza != NULL) { @@ -212,8 +225,7 @@ _message_error_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, // handle recipient not found if ((from != NULL) && ((type != NULL && (strcmp(type, "cancel") == 0)))) { char *cpy = strdup(from); - log_info("Recipient %s not found.", cpy); - handle_recipient_not_found(cpy); + handle_recipient_not_found(cpy, err_msg); } return 1; |