当前位置: 首页>>代码示例>>C++>>正文


C++ ExceptionRef::hasType方法代码示例

本文整理汇总了C++中ExceptionRef::hasType方法的典型用法代码示例。如果您正苦于以下问题:C++ ExceptionRef::hasType方法的具体用法?C++ ExceptionRef::hasType怎么用?C++ ExceptionRef::hasType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ExceptionRef的用法示例。


在下文中一共展示了ExceptionRef::hasType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sendUpdate

void ListingUpdater::sendUpdate(SellerListingUpdate& update)
{
   MO_CAT_DEBUG(BM_CUSTOMCATALOG_CAT,
      "ListingUpdater sending seller listing update for user %" PRIu64 ": %s",
      getUserId(), JsonWriter::writeToString(update).c_str());

   // create message to send after update
   DynamicObject msg;
   msg["updateResponse"] = true;
   msg["scheduleUpdateRequest"] = false;
   msg["error"] = false;

   // post to bitmunk
   DynamicObject result;
   Url url("/api/3.0/catalog/listings");
   Messenger* m = mNode->getMessenger();
   if(m->postSecureToBitmunk(&url, &update, &result, getUserId()))
   {
      // send result in message, include update ID separately so that
      // handling heartbeats above is simpler -- it doesn't matter if
      // the current update ID was valid or not, it will be stored in
      // "updateId" field
      msg["update"] = update;
      msg["updateResult"] = result;
      msg["updateId"] = result["updateId"]->getString();

      // if the update wasn't a heartbeat, include a note that another
      // update should be run immediately after this result is processed
      if(update["payeeSchemes"]["updates"]->length() > 0 ||
         update["payeeSchemes"]["removals"]->length() > 0 ||
         update["listings"]["updates"]->length() > 0 ||
         update["listings"]["removals"]->length() > 0)
      {
         msg["scheduleUpdateRequest"] = true;
      }
   }
   else
   {
      // if the error was an invalid update ID, do not record it as an error
      // and see if we can recover from it
      ExceptionRef ex = Exception::get();
      if(ex->isType("bitmunk.mastercatalog.UpdateIdNotCurrent"))
      {
         msg["updateIdNotCurrent"] = true;
         msg["updateId"] = ex->getDetails()["currentUpdateId"]->getString();
      }
      else
      {
         // FIXME: determine if error is a network error or if there
         // were just some bad wares that weren't accepted/bad remote update ID

         // failed to update
         ExceptionRef e = new Exception(
            "Could not send seller listing update.",
            "bitmunk.catalog.SellerListingUpdateError");
         Exception::push(e);
         DynamicObject d = Exception::getAsDynamicObject();
         msg["error"] = true;
         msg["exception"] = d;

         // see if we need to register for a new server ID because our catalog
         // expired and we no longer exist as a seller
         // FIXME: we want a different exception name for this
         if(ex->hasType("bitmunk.database.NotFound") ||
            ex->hasType("bitmunk.database.Catalog.InvalidServerToken"))
         {
            // log message ... do new server registration
            MO_CAT_DEBUG(BM_CUSTOMCATALOG_CAT,
               "ListingUpdater user's (user ID %" PRIu64
               ") seller does not exist, "
               "has expired, or server token is invalid: %s",
               getUserId(), JsonWriter::writeToString(d).c_str());
            msg["reset"] = true;
         }
         else
         {
            // log generic error
            MO_CAT_ERROR(BM_CUSTOMCATALOG_CAT,
               "ListingUpdater: %s", JsonWriter::writeToString(d).c_str());
         }
      }
   }

   // send message to self
   messageSelf(msg);

   // schedule a pending test net access request
   if(mTestNetAccessPending)
   {
      mTestNetAccessPending = false;
      DynamicObject msg;
      msg["testNetAccess"] = true;
      messageSelf(msg);
   }
}
开发者ID:digitalbazaar,项目名称:bitmunk,代码行数:95,代码来源:ListingUpdater.cpp


注:本文中的ExceptionRef::hasType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。