diff options
-rw-r--r-- | src/libutil/printf.c | 19 | ||||
-rw-r--r-- | src/libutil/printf.h | 1 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/libutil/printf.c b/src/libutil/printf.c index 5a04dc432..0cd043058 100644 --- a/src/libutil/printf.c +++ b/src/libutil/printf.c @@ -339,6 +339,7 @@ rspamd_vprintf_common (rspamd_printf_append_func func, guint width, sign, hex, humanize, bytes, frac_width, i; rspamd_fstring_t *v; GString *gs; + GError *err; gboolean bv; while (*fmt) { @@ -462,6 +463,24 @@ rspamd_vprintf_common (rspamd_printf_append_func func, continue; + case 'e': + err = va_arg (args, GError *); + + if (err) { + p = err->message; + + if (p == NULL) { + p = "(NULL)"; + } + } + else { + p = "unknown error"; + } + + slen = strlen (p); + RSPAMD_PRINTF_APPEND (p, slen); + break; + case 's': p = va_arg (args, gchar *); if (p == NULL) { diff --git a/src/libutil/printf.h b/src/libutil/printf.h index 2bc421143..d0db483d9 100644 --- a/src/libutil/printf.h +++ b/src/libutil/printf.h @@ -52,6 +52,7 @@ * %Z '\0' * %N '\n' * %c gchar + * %e GError * * %% % * */ |