From a8ebef92cbedc58fa0d361dd90bc153b39ed1f17 Mon Sep 17 00:00:00 2001 From: Christian Hohnstaedt Date: Sun, 29 Sep 2024 00:52:13 +0200 Subject: [PATCH] Extend Error messages by line and function Every detail can help --- lib/func_base.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/func_base.cpp b/lib/func_base.cpp index e7387731..ae96cfa3 100644 --- a/lib/func_base.cpp +++ b/lib/func_base.cpp @@ -159,14 +159,22 @@ void *d2i_bytearray(void *(*d2i)(void *, unsigned char **, long), return ret; } +static int __ecb(const char *st, size_t len, void *u) +{ + QByteArray *ba = (QByteArray *)u; + ba->append(st, len); + return 1; +} + void _openssl_error(const QString &txt, const char *file, int line) { QString error; + QByteArray ba; - while (int i = ERR_get_error() ) { - error += QString(ERR_error_string(i, NULL)) + "\n"; + ERR_print_errors_cb(__ecb, &ba); + if (!ba.isEmpty()) { fputs(CCHAR(QString("OpenSSL error (%1:%2) : %3\n"). - arg(file).arg(line).arg(ERR_error_string(i, NULL))), + arg(file).arg(line).arg(QString::fromLatin1(ba))), stderr); } if (!error.isEmpty()) {