Changeset View
Changeset View
Standalone View
Standalone View
kded/engine/commandresult.h
Show All 29 Lines | |||||
30 | 30 | | |||
31 | class Error { | 31 | class Error { | ||
32 | public: | 32 | public: | ||
33 | enum Code { | 33 | enum Code { | ||
34 | MountPointError, | 34 | MountPointError, | ||
35 | DeviceError, | 35 | DeviceError, | ||
36 | BackendError, | 36 | BackendError, | ||
37 | CommandError, | 37 | CommandError, | ||
38 | DeletionError | 38 | DeletionError, | ||
39 | UnknownError | ||||
39 | }; | 40 | }; | ||
40 | 41 | | |||
41 | Error(Code code, const QString &message = QString()); | 42 | Error(Code code = UnknownError, const QString &message = {}, const QString &out = {}, const QString &err = {}); | ||
42 | 43 | | |||
43 | Code code() const; | 44 | Code code() const; | ||
44 | QString message() const; | 45 | QString message() const; | ||
46 | QString out() const; | ||||
47 | QString err() const; | ||||
45 | 48 | | |||
46 | private: | 49 | private: | ||
47 | Code m_code; | 50 | Code m_code; | ||
48 | QString m_message; | 51 | QString m_message; | ||
52 | QString m_out; | ||||
53 | QString m_err; | ||||
49 | }; | 54 | }; | ||
50 | 55 | | |||
51 | 56 | | |||
52 | 57 | | |||
53 | template <typename T = void> | 58 | template <typename T = void> | ||
54 | using Result = AsynQt::Expected<T, Error>; | 59 | using Result = AsynQt::Expected<T, Error>; | ||
55 | 60 | | |||
56 | template <typename T = void> | 61 | template <typename T = void> | ||
57 | using FutureResult = QFuture<Result<T>>; | 62 | using FutureResult = QFuture<Result<T>>; | ||
58 | 63 | | |||
59 | 64 | | |||
60 | 65 | | |||
61 | inline | 66 | inline | ||
62 | FutureResult<> errorResult(Error::Code error, const QString &message) | 67 | FutureResult<> errorResult(Error::Code error, const QString &message, const QString &out = {}, const QString &err = {}) | ||
63 | { | 68 | { | ||
64 | qWarning() << message; | 69 | qWarning() << message; | ||
65 | return makeReadyFuture(Result<>::error(error, message)); | 70 | return makeReadyFuture(Result<>::error(error, message, out, err)); | ||
66 | } | 71 | } | ||
67 | 72 | | |||
68 | 73 | | |||
69 | } // namespace PlasmaVault | 74 | } // namespace PlasmaVault | ||
70 | 75 | | |||
71 | #endif // include guard | 76 | #endif // include guard | ||
72 | 77 | |