aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/include/winapi/error.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/winapi/error.hpp')
-rw-r--r--include/winapi/error.hpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/include/winapi/error.hpp b/include/winapi/error.hpp
new file mode 100644
index 0000000..4b3f1e0
--- /dev/null
+++ b/include/winapi/error.hpp
@@ -0,0 +1,35 @@
+// Copyright (c) 2020 Egor Tensin <Egor.Tensin@gmail.com>
+// This file is part of the "winapi-common" project.
+// For details, see https://github.com/egor-tensin/winapi-common.
+// Distributed under the MIT License.
+
+#pragma once
+
+#include <boost/config.hpp>
+
+#include <windows.h>
+
+#include <string>
+#include <system_error>
+
+namespace winapi {
+namespace error {
+
+class CategoryWindows : public std::error_category {
+public:
+ CategoryWindows() = default;
+
+ const char* name() const BOOST_NOEXCEPT_OR_NOTHROW { return "Windows"; }
+
+ std::string message(int) const;
+};
+
+inline const CategoryWindows& category_windows() {
+ static const CategoryWindows instance;
+ return instance;
+}
+
+std::system_error windows(DWORD code, const char* function);
+
+} // namespace error
+} // namespace winapi