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 {
20inline namespace v1 {
21
22[[nodiscard]] inline std::string get_last_error_message(uint32_t error_code)
23{
24 if (auto msg = win32_FormatMessage(static_cast<win32_error>(error_code))) {
25 return *msg;
26 } else {
27 throw std::system_error(msg.error());
28 }
29}
30
32 if (auto msg = win32_FormatMessage(win32_GetLastError())) {
33 return *msg;
34 } else {
35 throw std::system_error(msg.error());
36 }
37}
38
39}}
Rules for working with win32 headers.
DOXYGEN BUG.
Definition algorithm.hpp:16
geometry/margins.hpp
Definition lookahead_iterator.hpp:5
std::string get_last_error_message()
Get the OS error message from the last error received on this thread.
Definition exception_win32_impl.hpp:31
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:377