Music Hub ..
A session-wide music playback service
 
Loading...
Searching...
No Matches
error.h
Go to the documentation of this file.
1/*
2 * Copyright © 2021-2022 UBports Foundation.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef LOMIRI_MEDIAHUB_ERROR_H
18#define LOMIRI_MEDIAHUB_ERROR_H
19
20#include "global.h"
21
22#include <QDebug>
23#include <QMetaType>
24#include <QString>
25
26namespace lomiri {
27namespace MediaHub {
28
30{
31public:
42
43 Error(Code code = NoError, const QString &message = QString()):
44 m_code(code), m_message(message) {}
45
46 bool operator==(const Error &o) const {
47 return o.code() == code() && o.message() == message();
48 }
49
50 Code code() const { return m_code; }
51 bool isError() const { return m_code != NoError; }
52
53 const QString &message() const { return m_message; }
54
55 QString toString() const {
56 return m_message + QString(" (%1)").arg(m_code);
57 }
58
59private:
60 Code m_code;
61 QString m_message;
62};
63
64inline QDebug operator<<(QDebug dbg, const Error &error)
65{
66 dbg.nospace() << "Error(" << error.code() << "): " << error.message();
67 return dbg.maybeSpace();
68}
69
70} // namespace MediaHub
71} // namespace lomiri
72
73Q_DECLARE_METATYPE(lomiri::MediaHub::Error)
74
75#endif // LOMIRI_MEDIAHUB_ERROR_H
Error(Code code=NoError, const QString &message=QString())
Definition error.h:43
bool isError() const
Definition error.h:51
const QString & message() const
Definition error.h:53
@ OutOfProcessBufferStreamingNotSupported
Definition error.h:40
bool operator==(const Error &o) const
Definition error.h:46
Code code() const
Definition error.h:50
QString toString() const
Definition error.h:55
#define MH_EXPORT
Definition global.h:27
QDebug operator<<(QDebug dbg, const Error &error)
Definition error.h:64