Music Hub
..
A session-wide music playback service
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
26
namespace
lomiri
{
27
namespace
MediaHub {
28
29
class
MH_EXPORT
Error
30
{
31
public
:
32
enum
Code
{
33
NoError
,
34
ResourceError
,
35
FormatError
,
36
NetworkError
,
37
AccessDeniedError
,
38
ServiceMissingError
,
39
InternalError
,
40
OutOfProcessBufferStreamingNotSupported
,
41
};
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
59
private
:
60
Code m_code;
61
QString m_message;
62
};
63
64
inline
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
73
Q_DECLARE_METATYPE(
lomiri::MediaHub::Error
)
74
75
#endif // LOMIRI_MEDIAHUB_ERROR_H
lomiri::MediaHub::Error::Error
Error(Code code=NoError, const QString &message=QString())
Definition:
error.h:43
global.h
lomiri::MediaHub::operator<<
QDebug operator<<(QDebug dbg, const Error &error)
Definition:
error.h:64
lomiri::MediaHub::Error::Code
Code
Definition:
error.h:32
lomiri::MediaHub::Error::isError
bool isError() const
Definition:
error.h:51
lomiri::MediaHub::Error::code
Code code() const
Definition:
error.h:50
lomiri::MediaHub::Error::InternalError
@ InternalError
Definition:
error.h:39
MH_EXPORT
#define MH_EXPORT
Definition:
global.h:27
lomiri::MediaHub::Error::toString
QString toString() const
Definition:
error.h:55
lomiri::MediaHub::Error::ServiceMissingError
@ ServiceMissingError
Definition:
error.h:38
lomiri::MediaHub::Error::operator==
bool operator==(const Error &o) const
Definition:
error.h:46
lomiri::MediaHub::Error::ResourceError
@ ResourceError
Definition:
error.h:34
lomiri::MediaHub::Error::NoError
@ NoError
Definition:
error.h:33
lomiri::MediaHub::Error::OutOfProcessBufferStreamingNotSupported
@ OutOfProcessBufferStreamingNotSupported
Definition:
error.h:40
lomiri::MediaHub::Error::NetworkError
@ NetworkError
Definition:
error.h:36
lomiri::MediaHub::Error
Definition:
error.h:29
lomiri::MediaHub::Error::message
const QString & message() const
Definition:
error.h:53
lomiri::MediaHub::Error::AccessDeniedError
@ AccessDeniedError
Definition:
error.h:37
lomiri
Definition:
dbus_utils.h:24
DBusConstants::NoError
@ NoError
Definition:
dbus_constants.h:61
lomiri::MediaHub::Error::FormatError
@ FormatError
Definition:
error.h:35
src
lib
MediaHub
error.h
Generated on Fri Dec 16 2022 11:18:10 for Music Hub by
1.8.17