refactor: use QStrings for exceptions whats

This commit is contained in:
sithlord48 2025-12-16 10:52:17 -05:00 committed by Nick Bolton
parent 1c789fd6a9
commit 050397f5b3
18 changed files with 79 additions and 74 deletions

View file

@ -1,6 +1,6 @@
/* /*
* Deskflow -- mouse and keyboard sharing utility * Deskflow -- mouse and keyboard sharing utility
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers * SPDX-FileCopyrightText: (C) 2025 - 2026 Deskflow Developers
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd. * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman * SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
@ -20,7 +20,7 @@ BaseException::BaseException() : std::runtime_error("")
// do nothing // do nothing
} }
BaseException::BaseException(const std::string &msg) : std::runtime_error(msg) BaseException::BaseException(const QString &msg) : std::runtime_error(msg.toStdString())
{ {
// do nothing // do nothing
} }
@ -32,20 +32,20 @@ const char *BaseException::what() const throw()
} }
m_what = getWhat(); m_what = getWhat();
return m_what.c_str(); return qPrintable(m_what);
} }
std::string BaseException::format(const char * /*id*/, const char *fmt, ...) const noexcept QString BaseException::format(const char * /*id*/, const char *fmt, ...) const noexcept
{ {
// FIXME -- lookup message string using id as an index. set // FIXME -- lookup message string using id as an index. set
// fmt to that string if it exists. // fmt to that string if it exists.
// format // format
std::string result; QString result;
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
try { try {
result = deskflow::string::vformat(fmt, args); result = QString::fromStdString(deskflow::string::vformat(fmt, args));
} catch (...) { } catch (...) {
// ignore // ignore
result.clear(); result.clear();

View file

@ -1,6 +1,6 @@
/* /*
* Deskflow -- mouse and keyboard sharing utility * Deskflow -- mouse and keyboard sharing utility
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers * SPDX-FileCopyrightText: (C) 2025 - 2026 Deskflow Developers
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd. * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman * SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
@ -11,6 +11,8 @@
#include <stdexcept> #include <stdexcept>
#include <string> #include <string>
#include <QString>
//! Exception base class //! Exception base class
/*! /*!
This is the base class of most exception types. This is the base class of most exception types.
@ -21,7 +23,7 @@ public:
//! Use getWhat() as the result of what() //! Use getWhat() as the result of what()
BaseException(); BaseException();
//! Use \c msg as the result of what() //! Use \c msg as the result of what()
explicit BaseException(const std::string &msg); explicit BaseException(const QString &msg);
~BaseException() throw() override = default; ~BaseException() throw() override = default;
//! Reason for exception //! Reason for exception
@ -29,9 +31,9 @@ public:
protected: protected:
//! Get a human readable string describing the exception //! Get a human readable string describing the exception
virtual std::string getWhat() const noexcept virtual QString getWhat() const noexcept
{ {
return ""; return {};
} }
//! Format a string //! Format a string
@ -40,8 +42,8 @@ protected:
no format can be found, then replaces positional parameters in no format can be found, then replaces positional parameters in
the format string and returns the result. the format string and returns the result.
*/ */
virtual std::string format(const char *id, const char *defaultFormat, ...) const noexcept; virtual QString format(const char *id, const char *defaultFormat, ...) const noexcept;
private: private:
mutable std::string m_what; mutable QString m_what;
}; };

View file

@ -47,7 +47,7 @@ public:
// do nothing // do nothing
} }
bool m_retry = false; bool m_retry = false;
std::string m_what; QString m_what;
}; };
public: public:

View file

@ -182,7 +182,7 @@ void ClientApp::handleClientFailed(const Event &e)
// Try next resolved address for current hostname // Try next resolved address for current hostname
std::unique_ptr<Client::FailInfo> info(static_cast<Client::FailInfo *>(e.getData())); std::unique_ptr<Client::FailInfo> info(static_cast<Client::FailInfo *>(e.getData()));
LOG_WARN("failed to connect to server=%s, trying next resolved address", info->m_what.c_str()); LOG_WARN("failed to connect to server=%s, trying next resolved address", qPrintable(info->m_what));
if (!m_suspended) { if (!m_suspended) {
scheduleClientRestart(retryTime()); scheduleClientRestart(retryTime());
} }
@ -196,7 +196,7 @@ void ClientApp::handleClientFailed(const Event &e)
handleClientRefused(e); handleClientRefused(e);
} else { } else {
std::unique_ptr<Client::FailInfo> info(static_cast<Client::FailInfo *>(e.getData())); std::unique_ptr<Client::FailInfo> info(static_cast<Client::FailInfo *>(e.getData()));
LOG_WARN("failed to connect to server=%s, trying next server in list", info->m_what.c_str()); LOG_WARN("failed to connect to server=%s, trying next server in list", qPrintable(info->m_what));
if (!m_suspended) { if (!m_suspended) {
scheduleClientRestart(retryTime()); scheduleClientRestart(retryTime());
} }
@ -209,10 +209,10 @@ void ClientApp::handleClientRefused(const Event &e)
std::unique_ptr<Client::FailInfo> info(static_cast<Client::FailInfo *>(e.getData())); std::unique_ptr<Client::FailInfo> info(static_cast<Client::FailInfo *>(e.getData()));
if (!info->m_retry) { if (!info->m_retry) {
LOG_ERR("failed to connect to server: %s", info->m_what.c_str()); LOG_ERR("failed to connect to server: %s", qPrintable(info->m_what));
getEvents()->addEvent(Event(EventTypes::Quit)); getEvents()->addEvent(Event(EventTypes::Quit));
} else { } else {
LOG_WARN("failed to connect to server: %s", info->m_what.c_str()); LOG_WARN("failed to connect to server: %s", qPrintable(info->m_what));
if (!m_suspended) { if (!m_suspended) {
scheduleClientRestart(retryTime()); scheduleClientRestart(retryTime());
m_retryCount++; m_retryCount++;

View file

@ -1,6 +1,6 @@
/* /*
* Deskflow -- mouse and keyboard sharing utility * Deskflow -- mouse and keyboard sharing utility
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers * SPDX-FileCopyrightText: (C) 2025 - 2026 Deskflow Developers
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd. * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman * SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
@ -13,7 +13,7 @@
// BadClientException // BadClientException
// //
std::string BadClientException::getWhat() const throw() QString BadClientException::getWhat() const throw()
{ {
return "BadClientException"; return "BadClientException";
} }
@ -22,7 +22,7 @@ std::string BadClientException::getWhat() const throw()
// InvalidProtocolException // InvalidProtocolException
// //
std::string InvalidProtocolException::getWhat() const throw() QString InvalidProtocolException::getWhat() const throw()
{ {
return "InvalidProtocolException; Check the options section of the server " return "InvalidProtocolException; Check the options section of the server "
"configuration file has a valid protocol defined.\nProtocol must be barrier (default) or synergy." "configuration file has a valid protocol defined.\nProtocol must be barrier (default) or synergy."
@ -48,7 +48,7 @@ int IncompatibleClientException::getMinor() const noexcept
return m_minor; return m_minor;
} }
std::string IncompatibleClientException::getWhat() const throw() QString IncompatibleClientException::getWhat() const throw()
{ {
return format( return format(
"IncompatibleClientException", "incompatible client %{1}.%{2}", deskflow::string::sprintf("%d", m_major).c_str(), "IncompatibleClientException", "incompatible client %{1}.%{2}", deskflow::string::sprintf("%d", m_major).c_str(),
@ -70,7 +70,7 @@ const std::string &DuplicateClientException::getName() const noexcept
return m_name; return m_name;
} }
std::string DuplicateClientException::getWhat() const throw() QString DuplicateClientException::getWhat() const throw()
{ {
return format("DuplicateClientException", "duplicate client %{1}", m_name.c_str()); return format("DuplicateClientException", "duplicate client %{1}", m_name.c_str());
} }
@ -89,7 +89,7 @@ const std::string &UnknownClientException::getName() const noexcept
return m_name; return m_name;
} }
std::string UnknownClientException::getWhat() const throw() QString UnknownClientException::getWhat() const throw()
{ {
return format("UnknownClientException", "unknown client %{1}", m_name.c_str()); return format("UnknownClientException", "unknown client %{1}", m_name.c_str());
} }
@ -108,7 +108,7 @@ int ExitAppException::getCode() const noexcept
return m_code; return m_code;
} }
std::string ExitAppException::getWhat() const throw() QString ExitAppException::getWhat() const throw()
{ {
return format("ExitAppException", "exiting with code %{1}", deskflow::string::sprintf("%d", m_code).c_str()); return format("ExitAppException", "exiting with code %{1}", deskflow::string::sprintf("%d", m_code).c_str());
} }

View file

@ -1,6 +1,6 @@
/* /*
* Deskflow -- mouse and keyboard sharing utility * Deskflow -- mouse and keyboard sharing utility
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers * SPDX-FileCopyrightText: (C) 2025 - 2026 Deskflow Developers
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd. * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman * SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
@ -26,7 +26,7 @@ class BadClientException : public DeskflowException
using DeskflowException::DeskflowException; using DeskflowException::DeskflowException;
protected: protected:
std::string getWhat() const throw() override; QString getWhat() const throw() override;
}; };
/** /**
@ -37,7 +37,7 @@ class InvalidProtocolException : public DeskflowException
using DeskflowException::DeskflowException; using DeskflowException::DeskflowException;
protected: protected:
std::string getWhat() const throw() override; QString getWhat() const throw() override;
}; };
//! Incompatible client exception //! Incompatible client exception
@ -60,7 +60,7 @@ public:
//@} //@}
protected: protected:
std::string getWhat() const throw() override; QString getWhat() const throw() override;
private: private:
int m_major; int m_major;
@ -87,7 +87,7 @@ public:
//@} //@}
protected: protected:
std::string getWhat() const throw() override; QString getWhat() const throw() override;
private: private:
std::string m_name; std::string m_name;
@ -113,7 +113,7 @@ public:
//@} //@}
protected: protected:
std::string getWhat() const throw() override; QString getWhat() const throw() override;
private: private:
std::string m_name; std::string m_name;
@ -135,7 +135,7 @@ public:
int getCode() const noexcept; int getCode() const noexcept;
protected: protected:
std::string getWhat() const throw() override; QString getWhat() const throw() override;
private: private:
int m_code; int m_code;

View file

@ -1,5 +1,6 @@
/* /*
* Deskflow -- mouse and keyboard sharing utility * Deskflow -- mouse and keyboard sharing utility
* SPDX-FileCopyrightText: (C) 2026 Deskflow Developers
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd. * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman * SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
@ -567,7 +568,7 @@ void ProtocolUtil::readBytes(deskflow::IStream *stream, uint32_t len, std::strin
// XIOReadMismatch // XIOReadMismatch
// //
std::string XIOReadMismatch::getWhat() const throw() QString XIOReadMismatch::getWhat() const throw()
{ {
return format("XIOReadMismatch", "ProtocolUtil::readf() mismatch"); return format("XIOReadMismatch", "ProtocolUtil::readf() mismatch");
} }

View file

@ -1,5 +1,6 @@
/* /*
* Deskflow -- mouse and keyboard sharing utility * Deskflow -- mouse and keyboard sharing utility
* SPDX-FileCopyrightText: (C) 2026 Deskflow Developers
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd. * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman * SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
@ -102,5 +103,5 @@ class XIOReadMismatch : public IOException
{ {
public: public:
// BaseException overrides // BaseException overrides
std::string getWhat() const throw() override; QString getWhat() const throw() override;
}; };

View file

@ -1,6 +1,6 @@
/* /*
* Deskflow -- mouse and keyboard sharing utility * Deskflow -- mouse and keyboard sharing utility
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers * SPDX-FileCopyrightText: (C) 2025 - 2026 Deskflow Developers
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd. * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman * SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
@ -12,7 +12,7 @@
// ScreenOpenFailureException // ScreenOpenFailureException
// //
std::string ScreenOpenFailureException::getWhat() const throw() QString ScreenOpenFailureException::getWhat() const throw()
{ {
return format("ScreenOpenFailureException", "unable to open screen"); return format("ScreenOpenFailureException", "unable to open screen");
} }
@ -21,7 +21,7 @@ std::string ScreenOpenFailureException::getWhat() const throw()
// ScreenUnavailableException // ScreenUnavailableException
// //
std::string ScreenUnavailableException::getWhat() const throw() QString ScreenUnavailableException::getWhat() const throw()
{ {
return format("ScreenUnavailableException", "unable to open screen"); return format("ScreenUnavailableException", "unable to open screen");
} }

View file

@ -1,6 +1,6 @@
/* /*
* Deskflow -- mouse and keyboard sharing utility * Deskflow -- mouse and keyboard sharing utility
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers * SPDX-FileCopyrightText: (C) 2025 - 2026 Deskflow Developers
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd. * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman * SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
@ -26,7 +26,7 @@ class ScreenOpenFailureException : public ScreenException
using ScreenException::ScreenException; using ScreenException::ScreenException;
protected: protected:
std::string getWhat() const throw() override; QString getWhat() const throw() override;
}; };
//! Screen unavailable exception //! Screen unavailable exception
@ -42,5 +42,5 @@ public:
//@} //@}
protected: protected:
std::string getWhat() const throw() override; QString getWhat() const throw() override;
}; };

View file

@ -1,6 +1,6 @@
/* /*
* Deskflow -- mouse and keyboard sharing utility * Deskflow -- mouse and keyboard sharing utility
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers * SPDX-FileCopyrightText: (C) 2025 - 2026 Deskflow Developers
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd. * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman * SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
@ -12,7 +12,7 @@
// IOClosedException // IOClosedException
// //
std::string IOClosedException::getWhat() const throw() QString IOClosedException::getWhat() const throw()
{ {
return format("IOClosedException", "already closed"); return format("IOClosedException", "already closed");
} }
@ -21,7 +21,7 @@ std::string IOClosedException::getWhat() const throw()
// IOEndOfStreamException // IOEndOfStreamException
// //
std::string IOEndOfStreamException::getWhat() const throw() QString IOEndOfStreamException::getWhat() const throw()
{ {
return format("IOEndOfStreamException", "reached end of stream"); return format("IOEndOfStreamException", "reached end of stream");
} }
@ -30,7 +30,7 @@ std::string IOEndOfStreamException::getWhat() const throw()
// IOWouldBlockException // IOWouldBlockException
// //
std::string IOWouldBlockException::getWhat() const throw() QString IOWouldBlockException::getWhat() const throw()
{ {
return format("IOWouldBlockException", "stream operation would block"); return format("IOWouldBlockException", "stream operation would block");
} }

View file

@ -1,6 +1,6 @@
/* /*
* Deskflow -- mouse and keyboard sharing utility * Deskflow -- mouse and keyboard sharing utility
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers * SPDX-FileCopyrightText: (C) 2025 - 2026 Deskflow Developers
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd. * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman * SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
@ -34,7 +34,7 @@ class IOClosedException : public IOException
using IOException::IOException; using IOException::IOException;
protected: protected:
std::string getWhat() const throw() override; QString getWhat() const throw() override;
}; };
/** /**
@ -45,7 +45,7 @@ class IOEndOfStreamException : public IOException
using IOException::IOException; using IOException::IOException;
protected: protected:
std::string getWhat() const throw() override; QString getWhat() const throw() override;
}; };
/** /**
@ -56,5 +56,5 @@ class IOWouldBlockException : public IOException
using IOException::IOException; using IOException::IOException;
protected: protected:
std::string getWhat() const throw() override; QString getWhat() const throw() override;
}; };

View file

@ -1,6 +1,6 @@
/* /*
* Deskflow -- mouse and keyboard sharing utility * Deskflow -- mouse and keyboard sharing utility
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers * SPDX-FileCopyrightText: (C) 2025 - 2026 Deskflow Developers
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd. * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman * SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
@ -12,7 +12,7 @@
// MTThreadUnavailableException // MTThreadUnavailableException
// //
std::string MTThreadUnavailableException::getWhat() const throw() QString MTThreadUnavailableException::getWhat() const throw()
{ {
return format("MTThreadUnavailableException", "cannot create thread"); return format("MTThreadUnavailableException", "cannot create thread");
} }

View file

@ -1,6 +1,6 @@
/* /*
* Deskflow -- mouse and keyboard sharing utility * Deskflow -- mouse and keyboard sharing utility
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers * SPDX-FileCopyrightText: (C) 2025 - 2026 Deskflow Developers
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd. * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman * SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
@ -26,5 +26,5 @@ class MTThreadUnavailableException : public MTException
using MTException::MTException; using MTException::MTException;
protected: protected:
std::string getWhat() const throw() override; QString getWhat() const throw() override;
}; };

View file

@ -1,6 +1,6 @@
/* /*
* Deskflow -- mouse and keyboard sharing utility * Deskflow -- mouse and keyboard sharing utility
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers * SPDX-FileCopyrightText: (C) 2025 - 2026 Deskflow Developers
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd. * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman * SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
@ -36,7 +36,7 @@ int SocketAddressException::getPort() const noexcept
return m_port; return m_port;
} }
std::string SocketAddressException::getWhat() const throw() QString SocketAddressException::getWhat() const throw()
{ {
static const char *s_errorID[] = { static const char *s_errorID[] = {
"SocketAddressUnknownException", "SocketAddressNotFoundException", "SocketAddressNoAddressException", "SocketAddressUnknownException", "SocketAddressNotFoundException", "SocketAddressNoAddressException",
@ -57,7 +57,7 @@ std::string SocketAddressException::getWhat() const throw()
// SocketIOCloseException // SocketIOCloseException
// //
std::string SocketIOCloseException::getWhat() const throw() QString SocketIOCloseException::getWhat() const throw()
{ {
return format("SocketIOCloseException", "close: %{1}", what()); return format("SocketIOCloseException", "close: %{1}", what());
} }
@ -66,7 +66,7 @@ std::string SocketIOCloseException::getWhat() const throw()
// SocketBindException // SocketBindException
// //
std::string SocketBindException::getWhat() const throw() QString SocketBindException::getWhat() const throw()
{ {
return format("SocketBindException", "cannot bind address: %{1}", what()); return format("SocketBindException", "cannot bind address: %{1}", what());
} }
@ -75,7 +75,7 @@ std::string SocketBindException::getWhat() const throw()
// SocketAddressInUseException // SocketAddressInUseException
// //
std::string SocketAddressInUseException::getWhat() const throw() QString SocketAddressInUseException::getWhat() const throw()
{ {
return format("SocketAddressInUseException", "cannot bind address: %{1}", what()); return format("SocketAddressInUseException", "cannot bind address: %{1}", what());
} }
@ -84,7 +84,7 @@ std::string SocketAddressInUseException::getWhat() const throw()
// SocketConnectException // SocketConnectException
// //
std::string SocketConnectException::getWhat() const throw() QString SocketConnectException::getWhat() const throw()
{ {
return format("SocketConnectException", "cannot connect socket: %{1}", what()); return format("SocketConnectException", "cannot connect socket: %{1}", what());
} }
@ -93,7 +93,7 @@ std::string SocketConnectException::getWhat() const throw()
// SocketCreateException // SocketCreateException
// //
std::string SocketCreateException::getWhat() const throw() QString SocketCreateException::getWhat() const throw()
{ {
return format("SocketCreateException", "cannot create socket: %{1}", what()); return format("SocketCreateException", "cannot create socket: %{1}", what());
} }

View file

@ -1,6 +1,6 @@
/* /*
* Deskflow -- mouse and keyboard sharing utility * Deskflow -- mouse and keyboard sharing utility
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers * SPDX-FileCopyrightText: (C) 2025 - 2026 Deskflow Developers
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd. * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman * SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
@ -53,7 +53,7 @@ public:
protected: protected:
// BaseException overrides // BaseException overrides
std::string getWhat() const throw() override; QString getWhat() const throw() override;
private: private:
SocketError m_error; SocketError m_error;
@ -71,7 +71,7 @@ public:
{ {
// do nothing // do nothing
} }
explicit SocketIOCloseException(const std::string &msg) : IOCloseException(msg), m_state(kFirst) explicit SocketIOCloseException(const QString &msg) : IOCloseException(msg), m_state(kFirst)
{ {
// do nothing // do nothing
} }
@ -85,14 +85,14 @@ public:
m_state = kDone; m_state = kDone;
} }
if (m_state == kDone) { if (m_state == kDone) {
return m_formatted.c_str(); return qPrintable(m_formatted);
} else { } else {
return IOCloseException::what(); return IOCloseException::what();
} }
} }
protected: protected:
std::string getWhat() const throw() override; QString getWhat() const throw() override;
private: private:
enum EState enum EState
@ -102,7 +102,7 @@ private:
kDone kDone
}; };
mutable EState m_state; mutable EState m_state;
mutable std::string m_formatted; mutable QString m_formatted;
}; };
/** /**
@ -115,7 +115,7 @@ public:
{ {
// do nothing // do nothing
} }
explicit SocketWithWhatException(const std::string &msg) : SocketException(msg), m_state(kFirst) explicit SocketWithWhatException(const QString &msg) : SocketException(msg), m_state(kFirst)
{ {
// do nothing // do nothing
} }
@ -129,7 +129,7 @@ public:
m_state = kDone; m_state = kDone;
} }
if (m_state == kDone) { if (m_state == kDone) {
return m_formatted.c_str(); return qPrintable(m_formatted);
} else { } else {
return SocketException::what(); return SocketException::what();
} }
@ -143,7 +143,7 @@ private:
kDone kDone
}; };
mutable EState m_state; mutable EState m_state;
mutable std::string m_formatted; mutable QString m_formatted;
}; };
/** /**
@ -154,7 +154,7 @@ class SocketBindException : public SocketWithWhatException
using SocketWithWhatException::SocketWithWhatException; using SocketWithWhatException::SocketWithWhatException;
protected: protected:
std::string getWhat() const throw() override; QString getWhat() const throw() override;
}; };
/** /**
@ -166,7 +166,7 @@ class SocketAddressInUseException : public SocketWithWhatException
using SocketWithWhatException::SocketWithWhatException; using SocketWithWhatException::SocketWithWhatException;
protected: protected:
std::string getWhat() const throw() override; QString getWhat() const throw() override;
}; };
/** /**
@ -177,7 +177,7 @@ class SocketConnectException : public SocketWithWhatException
using SocketWithWhatException::SocketWithWhatException; using SocketWithWhatException::SocketWithWhatException;
protected: protected:
std::string getWhat() const throw() override; QString getWhat() const throw() override;
}; };
/** /**
@ -188,5 +188,5 @@ class SocketCreateException : public SocketWithWhatException
using SocketWithWhatException::SocketWithWhatException; using SocketWithWhatException::SocketWithWhatException;
protected: protected:
std::string getWhat() const throw() override; QString getWhat() const throw() override;
}; };

View file

@ -1,6 +1,6 @@
/* /*
* Deskflow -- mouse and keyboard sharing utility * Deskflow -- mouse and keyboard sharing utility
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers * SPDX-FileCopyrightText: (C) 2025 - 2026 Deskflow Developers
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd. * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman * SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
@ -2066,7 +2066,7 @@ ServerConfigReadException::ServerConfigReadException(
// do nothing // do nothing
} }
std::string ServerConfigReadException::getWhat() const throw() QString ServerConfigReadException::getWhat() const throw()
{ {
return format("ServerConfigReadException", "read error: %{1}", m_error.c_str()); return format("ServerConfigReadException", "read error: %{1}", m_error.c_str());
} }

View file

@ -1,5 +1,6 @@
/* /*
* Deskflow -- mouse and keyboard sharing utility * Deskflow -- mouse and keyboard sharing utility
* SPDX-FileCopyrightText: (C) 2026 Deskflow Developers
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd. * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman * SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
@ -537,7 +538,7 @@ public:
protected: protected:
// BaseException overrides // BaseException overrides
std::string getWhat() const throw() override; QString getWhat() const throw() override;
private: private:
std::string m_error; std::string m_error;