diff --git a/msix/storeapi/StoreApi.cpp b/msix/storeapi/StoreApi.cpp index 378327ce8..bc07ff508 100644 --- a/msix/storeapi/StoreApi.cpp +++ b/msix/storeapi/StoreApi.cpp @@ -46,16 +46,16 @@ void logError(std::string_view functionName, std::string_view errMsg) { Int GetSubscriptionExpirationDate(const char* productID, std::int64_t* expirationUnix) { - if (auto err = validateArg(productID, MaxProductIdLen); - err != StoreApi::ErrorCode::None) { - return toInt(err); - } + try { + if (auto err = validateArg(productID, MaxProductIdLen); + err != StoreApi::ErrorCode::None) { + return toInt(err); + } - if (expirationUnix == nullptr) { - return toInt(StoreApi::ErrorCode::NullOutputPtr); - } + if (expirationUnix == nullptr) { + return toInt(StoreApi::ErrorCode::NullOutputPtr); + } - try { StoreApi::ServerStoreService service{}; *expirationUnix = service.CurrentExpirationDate(productID); @@ -75,16 +75,16 @@ Int GetSubscriptionExpirationDate(const char* productID, Int GenerateUserJWT(const char* accessToken, char** userJWT, std::uint64_t* userJWTLen) { - if (auto err = validateArg(accessToken, MaxTokenLen); - err != StoreApi::ErrorCode::None) { - return toInt(err); - } + try { + if (auto err = validateArg(accessToken, MaxTokenLen); + err != StoreApi::ErrorCode::None) { + return toInt(err); + } - if (userJWT == nullptr || userJWTLen == nullptr) { - return toInt(StoreApi::ErrorCode::NullOutputPtr); - } + if (userJWT == nullptr || userJWTLen == nullptr) { + return toInt(StoreApi::ErrorCode::NullOutputPtr); + } - try { StoreApi::ServerStoreService service{}; auto user = service.CurrentUserInfo(); const std::string jwt = service.GenerateUserJwt(accessToken, user); diff --git a/msix/storeapi/dllmain.cpp b/msix/storeapi/dllmain.cpp index 938f1e3f7..27d4bea0f 100644 --- a/msix/storeapi/dllmain.cpp +++ b/msix/storeapi/dllmain.cpp @@ -1,19 +1,26 @@ // dllmain.cpp : Defines the entry point for the DLL application. +#include + #include "framework.hpp" -BOOL APIENTRY DllMain( HMODULE hModule, - DWORD ul_reason_for_call, - LPVOID lpReserved - ) -{ - switch (ul_reason_for_call) - { +#ifdef _MSC_VER +#include +#else +constexpr void _CrtSetReportHook(auto) {} +#endif // _MSC_VER + +BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, + LPVOID lpReserved) { + _CrtSetReportHook([](int reportType, char* message, int* returnValue) -> int { + throw std::runtime_error(message); + }); + + switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DETACH: - break; - } - return TRUE; + break; + } + return TRUE; } -