From dcadd5a52dadb244d93167dca94a747ed42e2f08 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Mon, 9 Aug 2021 14:12:59 +0200 Subject: Added ThrowLastError which accepts a std::source_location --- zencore/except.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'zencore/except.cpp') diff --git a/zencore/except.cpp b/zencore/except.cpp index 882f69f9a..124b9455f 100644 --- a/zencore/except.cpp +++ b/zencore/except.cpp @@ -2,6 +2,7 @@ #include #include +#include namespace zen { @@ -24,4 +25,11 @@ ThrowLastError(std::string_view Message) throw std::system_error(std::error_code(::GetLastError(), std::system_category()), std::string(Message)); } +void +ThrowLastError(std::string_view Message, const std::source_location& Location) +{ + using namespace fmt::literals; + throw std::system_error(std::error_code(::GetLastError(), std::system_category()), "{}({}): {}"_format(Location.file_name(), Location.line(), Message)); +} + } // namespace zen -- cgit v1.2.3