aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Ridgers <[email protected]>2022-01-07 14:41:45 +0100
committerMartin Ridgers <[email protected]>2022-01-07 14:56:28 +0100
commitfa86dbd4af6ff50fe21f909727676e2867f0b168 (patch)
tree1d8428aabb4433fd2e4a19038723c36f9de8b492
parentRemoved unused lambda captures (diff)
downloadzen-fa86dbd4af6ff50fe21f909727676e2867f0b168.tar.xz
zen-fa86dbd4af6ff50fe21f909727676e2867f0b168.zip
Turn all ThrowLastError() sites in source_location variants
-rw-r--r--zencore/except.cpp14
-rw-r--r--zencore/include/zencore/except.h7
-rw-r--r--zenutil/zenserverprocess.cpp3
3 files changed, 12 insertions, 12 deletions
diff --git a/zencore/except.cpp b/zencore/except.cpp
index fae629286..b4ad5acf2 100644
--- a/zencore/except.cpp
+++ b/zencore/except.cpp
@@ -58,12 +58,6 @@ ThrowSystemException([[maybe_unused]] HRESULT hRes, [[maybe_unused]] std::string
#endif // ZEN_PLATFORM_WINDOWS
void
-ThrowLastError(std::string_view Message)
-{
- throw std::system_error(std::error_code(zen::GetLastError(), std::system_category()), std::string(Message));
-}
-
-void
ThrowSystemError(uint32_t ErrorCode, std::string_view Message)
{
throw std::system_error(std::error_code(ErrorCode, std::system_category()), std::string(Message));
@@ -83,12 +77,18 @@ GetSystemErrorAsString(uint32_t ErrorCode)
#if defined(__cpp_lib_source_location)
void
-ThrowLastError(std::string_view Message, const std::source_location& Location)
+ThrowLastErrorImpl(std::string_view Message, const std::source_location& Location)
{
using namespace fmt::literals;
throw std::system_error(std::error_code(zen::GetLastError(), std::system_category()),
"{}({}): {}"_format(Location.file_name(), Location.line(), Message));
}
+#else
+void
+ThrowLastError(std::string_view Message)
+{
+ throw std::system_error(std::error_code(zen::GetLastError(), std::system_category()), std::string(Message));
+}
#endif
} // namespace zen
diff --git a/zencore/include/zencore/except.h b/zencore/include/zencore/except.h
index 6719c1319..d714b6ade 100644
--- a/zencore/include/zencore/except.h
+++ b/zencore/include/zencore/except.h
@@ -20,10 +20,11 @@ namespace zen {
ZENCORE_API void ThrowSystemException [[noreturn]] (HRESULT hRes, std::string_view Message);
#endif // ZEN_PLATFORM_WINDOWS
-ZENCORE_API void ThrowLastError [[noreturn]] (std::string_view Message);
-
#if defined(__cpp_lib_source_location)
-ZENCORE_API void ThrowLastError [[noreturn]] (std::string_view Message, const std::source_location& Location);
+ZENCORE_API void ThrowLastErrorImpl [[noreturn]] (std::string_view Message, const std::source_location& Location);
+#define ThrowLastError(Message) ThrowLastErrorImpl(Message, std::source_location::current())
+#else
+ZENCORE_API void ThrowLastError [[noreturn]] (std::string_view Message);
#endif
ZENCORE_API void ThrowSystemError [[noreturn]] (uint32_t ErrorCode, std::string_view Message);
diff --git a/zenutil/zenserverprocess.cpp b/zenutil/zenserverprocess.cpp
index 93886a6b7..8eb510bb5 100644
--- a/zenutil/zenserverprocess.cpp
+++ b/zenutil/zenserverprocess.cpp
@@ -11,7 +11,6 @@
#include <zencore/thread.h>
#include <atomic>
-#include <source_location>
#if ZEN_PLATFORM_WINDOWS
# include <atlbase.h>
@@ -52,7 +51,7 @@ namespace zenutil {
{
if (!SetSecurityDescriptorDacl(&m_Sd, TRUE, (PACL)NULL, FALSE))
{
- ThrowLastError("SetSecurityDescriptorDacl failed", std::source_location::current());
+ ThrowLastError("SetSecurityDescriptorDacl failed");
}
m_Attributes.lpSecurityDescriptor = &m_Sd;