2012-06-10 16:50:54 +00:00
|
|
|
/*
|
2024-09-17 19:00:25 +00:00
|
|
|
* Deskflow -- mouse and keyboard sharing utility
|
2025-01-24 00:11:17 +00:00
|
|
|
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
|
|
|
|
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
2012-06-10 16:50:54 +00:00
|
|
|
*/
|
|
|
|
|
|
2014-02-28 12:36:45 +00:00
|
|
|
#pragma once
|
2012-06-10 16:50:54 +00:00
|
|
|
|
2025-03-20 23:35:21 +00:00
|
|
|
#include <stdexcept>
|
2025-01-06 00:55:07 +00:00
|
|
|
#include <string>
|
2012-06-10 16:50:54 +00:00
|
|
|
|
|
|
|
|
//! Exception base class
|
|
|
|
|
/*!
|
|
|
|
|
This is the base class of most exception types.
|
|
|
|
|
*/
|
2024-10-17 18:04:35 +00:00
|
|
|
class XBase : public std::runtime_error
|
|
|
|
|
{
|
2012-06-10 16:50:54 +00:00
|
|
|
public:
|
2024-07-02 19:07:06 +00:00
|
|
|
//! Use getWhat() as the result of what()
|
|
|
|
|
XBase();
|
|
|
|
|
//! Use \c msg as the result of what()
|
2025-05-21 01:09:55 +00:00
|
|
|
explicit XBase(const std::string &msg);
|
2025-05-01 14:48:13 +00:00
|
|
|
~XBase() throw() override = default;
|
2012-06-10 16:50:54 +00:00
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
//! Reason for exception
|
2025-04-28 01:27:48 +00:00
|
|
|
const char *what() const throw() override;
|
2012-06-10 16:50:54 +00:00
|
|
|
|
|
|
|
|
protected:
|
2024-07-02 19:07:06 +00:00
|
|
|
//! Get a human readable string describing the exception
|
2025-07-08 01:45:40 +00:00
|
|
|
virtual std::string getWhat() const noexcept
|
2024-10-17 18:04:35 +00:00
|
|
|
{
|
|
|
|
|
return "";
|
|
|
|
|
}
|
2024-07-02 19:07:06 +00:00
|
|
|
|
|
|
|
|
//! Format a string
|
|
|
|
|
/*!
|
|
|
|
|
Looks up a message format using \c id, using \c defaultFormat if
|
|
|
|
|
no format can be found, then replaces positional parameters in
|
|
|
|
|
the format string and returns the result.
|
|
|
|
|
*/
|
2025-07-08 01:45:40 +00:00
|
|
|
virtual std::string format(const char *id, const char *defaultFormat, ...) const noexcept;
|
2012-06-10 16:50:54 +00:00
|
|
|
|
2014-03-31 13:56:41 +00:00
|
|
|
private:
|
2025-01-06 00:55:07 +00:00
|
|
|
mutable std::string m_what;
|
2012-06-10 16:50:54 +00:00
|
|
|
};
|