Qx v0.5.7
Qt Extensions Library
Loading...
Searching...
No Matches
qx-systemerror.h
1#ifndef QX_SYSTEMERROR_H
2#define QX_SYSTEMERROR_H
3
4// Shared Lib Support
5#include "qx/core/qx_core_export.h"
6
7// Intra-component Includes
9
11#ifdef _WIN32
12 typedef long LONG;
13 using HRESULT = LONG;
14 using NTSTATUS = LONG;
15#endif
18namespace Qx
19{
20
21class QX_CORE_EXPORT SystemError final : public AbstractError<"Qx::SystemError", 2>
22{
23//-Class Enums------------------------------------------------------------------------------------------------
24public:
32
33//-Class Variables------------------------------------------------------------------------------------------------
34private:
35 static inline const QString UKNOWN_CAUSE = u"An unknown error occured"_s;
36
37//-Instance Variables------------------------------------------------------------------------------------------------
38private:
39 quint32 mValue;
40 OriginalFormat mOriginalFormat;
41 QString mActionError;
42 QString mCause;
43 Severity mSeverity;
44
45//-Constructor----------------------------------------------------------------------------------------------------------
46public:
48
49//-Class Functions--------------------------------------------------------------------------------------------
50public:
51#ifdef _WIN32
52 static SystemError fromHresult(HRESULT res, QString aError = u"System Error"_s);
53 static SystemError fromNtStatus(NTSTATUS res, QString aError = u"System Error"_s);
54#endif
55
56#ifdef __linux__
57 static SystemError fromErrno(int err, QString aError = "System Error");
58#endif
59
60//-Instance Functions---------------------------------------------------------------------------------------------------
61private:
62 quint32 deriveValue() const override;
63 Severity deriveSeverity() const override;
64 QString derivePrimary() const override;
65 QString deriveSecondary() const override;
66
67public:
68 bool isValid() const;
69 OriginalFormat originalFormat() const;
70 quint32 value() const;
71 QString actionError() const;
72 QString cause() const;
73};
74
75}
76
77#endif // QX_SYSTEMERROR_H
The AbstractError template class completes the Error interface and acts as the base class from which ...
Definition qx-abstracterror.h:86
The SystemError class encapsulates system generated errors as an Qx::Error interface compatible objec...
Definition qx-systemerror.h:22
OriginalFormat
Definition qx-systemerror.h:26
@ NtStatus
Definition qx-systemerror.h:29
@ Invalid
Definition qx-systemerror.h:27
@ Hresult
Definition qx-systemerror.h:28
The Qx namespace is the main namespace through which all non-global functionality of the Qx library i...
Definition qx-processwaiter.cpp:5
Severity
Definition qx-global.h:11
The qx-abstracterror.h header file provides access to the base class from which custom error types sh...
LONG NTSTATUS
Definition qx-windefs.h:7
LONG HRESULT
Definition qx-windefs.h:6
long LONG
Definition qx-windefs.h:5