From 8fe642b86c85ec45f27424108d7a5d6fae25fe25 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Wed, 14 Oct 2020 03:10:23 +0300 Subject: add error-handling functions They are almost exact copies from my pdb-repo project at https://github.com/egor-tensin/pdb-repo/tree/fa2afec5e7af45e7f1440b2d32c2a4e63dad6a62 I'm currently thinking about renaming it to winapi-debug BTW. --- include/winapi/error.hpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 include/winapi/error.hpp (limited to 'include/winapi') 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 +// 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 + +#include + +#include +#include + +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 -- cgit v1.2.3