Skip to content

Commit

Permalink
Expand coverage of try-catch so that assertion errors are always caught
Browse files Browse the repository at this point in the history
  • Loading branch information
EduardGomezEscandell committed Sep 26, 2023
1 parent 6f28e2a commit c0d5d6a
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions msix/storeapi/StoreApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit c0d5d6a

Please sign in to comment.