From 9e6bef29b6b48760f0f374d8ebe7af93a08241f6 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Thu, 26 Aug 2021 16:14:21 +0200 Subject: Added GetLastErrorAsString() to retrieve error string for last Windows API error. Should ultimately be replaced with some more platform agnostic implementation --- zencore/except.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'zencore/except.cpp') diff --git a/zencore/except.cpp b/zencore/except.cpp index 68b9e9a9b..00cb826f6 100644 --- a/zencore/except.cpp +++ b/zencore/except.cpp @@ -25,6 +25,12 @@ ThrowLastError(std::string_view Message) throw std::system_error(std::error_code(::GetLastError(), std::system_category()), std::string(Message)); } +std::string +GetLastErrorAsString() +{ + throw std::error_code(::GetLastError(), std::system_category()).message(); +} + void ThrowLastError(std::string_view Message, const std::source_location& Location) { -- cgit v1.2.3