HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
exception_win32_impl.hpp
1// Copyright Take Vos 2023.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
8#include "../macros.hpp"
9#include "../win32/win32.hpp"
10#include "defer.hpp"
11#include "exception_intf.hpp"
12#include <type_traits>
13#include <string>
14#include <string_view>
15#include <format>
16
17hi_export_module(hikogui.utility.exception : impl);
18
19hi_export namespace hi { inline namespace v1 {
20
21hi_export [[nodiscard]] inline std::string get_last_error_message(uint32_t error_code)
22{
23 if (auto msg = win32_FormatMessage(static_cast<win32_error>(error_code))) {
24 return *msg;
25 } else {
26 throw std::system_error(msg.error());
27 }
28}
29
30hi_export [[nodiscard]] inline std::string get_last_error_message()
31{
32 if (auto msg = win32_FormatMessage(win32_GetLastError())) {
33 return *msg;
34 } else {
35 throw std::system_error(msg.error());
36 }
37}
38
39}} // namespace hi::v1
Rules for working with win32 headers.
The HikoGUI namespace.
Definition array_generic.hpp:20
hi_export std::string get_last_error_message()
Get the OS error message from the last error received on this thread.
Definition exception_win32_impl.hpp:30
DOXYGEN BUG.
Definition algorithm_misc.hpp:20