Nameless Engine
Loading...
Searching...
No Matches
Error.h
1#pragma once
2
3// Standard.
4#include <string_view>
5#include <vector>
6#include <string>
7#include <source_location>
8
9// OS.
10#if defined(WIN32)
11#include <Windows.h>
12#endif
13
14namespace ne {
18 std::string sFilename;
19
21 std::string sLine;
22 };
23
27 class Error {
28 public:
35 Error(
36 std::string_view sMessage,
37 const std::source_location location = std::source_location::current()); // NOLINT
38
39#if defined(WIN32)
46 Error(const HRESULT hResult, const std::source_location location = std::source_location::current());
47
54 Error(
55 unsigned long iErrorCode, const std::source_location location = std::source_location::current());
56#endif
57
58 Error() = delete;
59 virtual ~Error() = default;
60
66 Error(const Error& other) = default;
67
75 Error& operator=(const Error& other) = default;
76
82 Error(Error&& other) = default;
83
91 Error& operator=(Error&& other) = default;
92
99 const std::source_location location = std::source_location::current()); // NOLINT
100
106 std::string getFullErrorMessage() const;
107
113 std::string getInitialMessage() const;
114
118 void showError() const;
119
120 protected:
128 static SourceLocationInfo sourceLocationToInfo(const std::source_location& location);
129
130 private:
132 std::string sMessage;
133
135 std::vector<SourceLocationInfo> stack;
136 };
137} // namespace ne
Definition: Error.h:27
std::string getFullErrorMessage() const
Definition: Error.cpp:84
Error & operator=(Error &&other)=default
std::string getInitialMessage() const
Definition: Error.cpp:100
Error & operator=(const Error &other)=default
std::string sMessage
Definition: Error.h:132
static SourceLocationInfo sourceLocationToInfo(const std::source_location &location)
Definition: Error.cpp:116
std::vector< SourceLocationInfo > stack
Definition: Error.h:135
void addCurrentLocationToErrorStack(const std::source_location location=std::source_location::current())
Definition: Error.cpp:80
Error(const Error &other)=default
void showError() const
Definition: Error.cpp:102
Error(Error &&other)=default
Definition: Error.h:16
std::string sLine
Definition: Error.h:21
std::string sFilename
Definition: Error.h:18