// Copyright Epic Games, Inc. All Rights Reserved. #include #include #include namespace zen { void ThrowSystemException([[maybe_unused]] HRESULT hRes, [[maybe_unused]] std::string_view Message) { if (HRESULT_FACILITY(hRes) == FACILITY_WIN32) { throw std::system_error(std::error_code(hRes & 0xffff, std::system_category()), std::string(Message)); } else { throw WindowsException(hRes, Message); } } void 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