[FSD] Also log/display socker error string

This commit is contained in:
Klaus Basan
2020-04-22 16:15:06 +02:00
committed by Mat Sutcliffe
parent 1a71d8afe1
commit 15b3ac2daa
2 changed files with 15 additions and 3 deletions

View File

@@ -1471,12 +1471,12 @@ namespace BlackCore
void CFSDClient::printSocketError(QAbstractSocket::SocketError socketError) void CFSDClient::printSocketError(QAbstractSocket::SocketError socketError)
{ {
CLogMessage(this).error(u"FSD socket error: %1") << socketErrorToQString(socketError); CLogMessage(this).error(u"FSD socket error: %1") << this->socketErrorString(socketError);
} }
void CFSDClient::handleSocketError(QAbstractSocket::SocketError socketError) void CFSDClient::handleSocketError(QAbstractSocket::SocketError socketError)
{ {
const QString error = socketErrorToQString(socketError); const QString error = this->socketErrorString(socketError);
switch (socketError) switch (socketError)
{ {
// all named here need a logoff // all named here need a logoff
@@ -1850,6 +1850,7 @@ namespace BlackCore
QPointer<CFSDClient> myself(this); QPointer<CFSDClient> myself(this);
QTimer::singleShot(DelayMs, this, [ = ] QTimer::singleShot(DelayMs, this, [ = ]
{ {
if (!sApp || sApp->isShuttingDown()) { return; }
if (myself) { myself->readDataFromSocketMaxLines(newMax); } if (myself) { myself->readDataFromSocketMaxLines(newMax); }
}); });
break; break;
@@ -1858,6 +1859,16 @@ namespace BlackCore
} }
} }
QString CFSDClient::socketErrorString(QAbstractSocket::SocketError error) const
{
QString e = CFSDClient::socketErrorToQString(error);
if (!m_socket.errorString().isEmpty())
{
e += QStringLiteral(": ") % m_socket.errorString();
}
return e;
}
QString CFSDClient::socketErrorToQString(QAbstractSocket::SocketError error) QString CFSDClient::socketErrorToQString(QAbstractSocket::SocketError error)
{ {
static const QMetaEnum metaEnum = QMetaEnum::fromType<QAbstractSocket::SocketError>(); static const QMetaEnum metaEnum = QMetaEnum::fromType<QAbstractSocket::SocketError>();

View File

@@ -333,7 +333,8 @@ namespace BlackCore
void readDataFromSocket() { this->readDataFromSocketMaxLines(); } void readDataFromSocket() { this->readDataFromSocketMaxLines(); }
void readDataFromSocketMaxLines(int maxLines = -1); void readDataFromSocketMaxLines(int maxLines = -1);
QString socketErrorToQString(QAbstractSocket::SocketError error); QString socketErrorString(QAbstractSocket::SocketError error) const;
static QString socketErrorToQString(QAbstractSocket::SocketError error);
void parseMessage(const QString &lineRaw); void parseMessage(const QString &lineRaw);
//! Init. the message types //! Init. the message types