diff options
| author | Stefan Boberg <[email protected]> | 2021-08-26 16:14:21 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-08-26 16:14:21 +0200 |
| commit | 9e6bef29b6b48760f0f374d8ebe7af93a08241f6 (patch) | |
| tree | 26312b31176028791062aab80bf741cded63b976 /zencore | |
| parent | trivial: Simple comment edit (diff) | |
| download | zen-9e6bef29b6b48760f0f374d8ebe7af93a08241f6.tar.xz zen-9e6bef29b6b48760f0f374d8ebe7af93a08241f6.zip | |
Added GetLastErrorAsString() to retrieve error string for last Windows API error.
Should ultimately be replaced with some more platform agnostic implementation
Diffstat (limited to 'zencore')
| -rw-r--r-- | zencore/except.cpp | 6 | ||||
| -rw-r--r-- | zencore/include/zencore/except.h | 1 |
2 files changed, 7 insertions, 0 deletions
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) { diff --git a/zencore/include/zencore/except.h b/zencore/include/zencore/except.h index ca0539d6e..0ae31dc71 100644 --- a/zencore/include/zencore/except.h +++ b/zencore/include/zencore/except.h @@ -54,5 +54,6 @@ ThrowSystemException(const char* Message) ZENCORE_API void ThrowLastError(std::string_view Message); ZENCORE_API void ThrowLastError(std::string_view Message, const std::source_location& Location); +ZENCORE_API std::string GetLastErrorAsString(); } // namespace zen |