fix: change QString to QByteArray for exception message handling

This commit is contained in:
Nick Bolton 2026-05-26 16:34:16 +01:00 committed by Chris Rizzitello
parent 6212f9bec6
commit bf65080b8b
3 changed files with 12 additions and 9 deletions

View file

@ -31,8 +31,8 @@ const char *BaseException::what() const throw()
return what;
}
m_what = getWhat();
return qPrintable(m_what);
m_what = getWhat().toLocal8Bit();
return m_what.constData();
}
QString BaseException::format(const char * /*id*/, const char *fmt, ...) const noexcept

View file

@ -11,6 +11,7 @@
#include <stdexcept>
#include <string>
#include <QByteArray>
#include <QString>
//! Exception base class
@ -45,5 +46,5 @@ protected:
virtual QString format(const char *id, const char *defaultFormat, ...) const noexcept;
private:
mutable QString m_what;
mutable QByteArray m_what;
};

View file

@ -11,6 +11,8 @@
#include "base/BaseException.h"
#include "io/IOException.h"
#include <QByteArray>
/**
* @brief SocketException generic socket exception
*/
@ -81,11 +83,11 @@ public:
{
if (m_state == kFirst) {
m_state = kFormat;
m_formatted = getWhat();
m_formatted = getWhat().toLocal8Bit();
m_state = kDone;
}
if (m_state == kDone) {
return qPrintable(m_formatted);
return m_formatted.constData();
} else {
return IOCloseException::what();
}
@ -102,7 +104,7 @@ private:
kDone
};
mutable EState m_state;
mutable QString m_formatted;
mutable QByteArray m_formatted;
};
/**
@ -125,11 +127,11 @@ public:
{
if (m_state == kFirst) {
m_state = kFormat;
m_formatted = getWhat();
m_formatted = getWhat().toLocal8Bit();
m_state = kDone;
}
if (m_state == kDone) {
return qPrintable(m_formatted);
return m_formatted.constData();
} else {
return SocketException::what();
}
@ -143,7 +145,7 @@ private:
kDone
};
mutable EState m_state;
mutable QString m_formatted;
mutable QByteArray m_formatted;
};
/**