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


C++ Exception::getDetails方法代码示例

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


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

示例1: waitUntilReady

bool AbstractSocket::waitUntilReady(bool read, int64_t timeout)
{
   Exception* e = NULL;

   // wait for readability/writability
   int error = SocketTools::poll(read, mFileDescriptor, timeout);
   if(error < 0)
   {
      if(errno == EINTR)
      {
         const char* msg = read ?
            "Socket read interrupted." :
            "Socket write interrupted.";

         // interrupted exception
         e = new Exception(msg, "monarch.io.InterruptedException");
         e->getDetails()["error"] = strerror(errno);
      }
      else
      {
         const char* msg = read ?
            "Could not read from socket." :
            "Could not write to socket.";

         // error occurred, get string message
         e = new Exception(msg, SOCKET_EXCEPTION_TYPE);
         e->getDetails()["error"] = strerror(errno);

         // clear file descriptor and close if its bad
         if(errno == EBADF)
         {
            mFileDescriptor = -1;
            close();
         }
      }
   }
   else if(error == 0)
   {
      const char* msg = read ?
         "Socket read timed out." :
         "Socket write timed out.";

      // timeout occurred, get string message
      e = new Exception(msg, SOCKET_TIMEOUT_EXCEPTION_TYPE);
      e->getDetails()["error"] = strerror(errno);
   }

   if(e != NULL)
   {
      ExceptionRef ref = e;
      Exception::set(ref);
   }

   return e == NULL;
}
开发者ID:bsletten,项目名称:monarch,代码行数:55,代码来源:AbstractSocket.cpp

示例2: createInterruptedException

Exception* Thread::createInterruptedException()
{
   Exception* rval = NULL;

   rval = new Exception("Thread interrupted", "monarch.rt.Interrupted");
   const char* name = getName();
   rval->getDetails()["name"] = ((name == NULL) ? "" : name);

   return rval;
}
开发者ID:bsletten,项目名称:monarch,代码行数:10,代码来源:Thread.cpp

示例3: waitUntilReady

bool AbstractSocket::waitUntilReady(bool read, int64_t timeout)
{
   Exception* e = NULL;

   // wait for readability/writability
   int error = SocketTools::poll(read, mFileDescriptor, timeout);
   if(error < 0)
   {
      if(errno == EINTR)
      {
         if(read)
         {
            // interrupted exception
            e = new Exception(
               "Socket read interrupted.", "monarch.io.InterruptedException");
            e->getDetails()["error"] = strerror(errno);
         }
         else
         {
            // interrupted exception
            e = new Exception(
               "Socket write interrupted.", "monarch.io.InterruptedException");
            e->getDetails()["error"] = strerror(errno);
         }
      }
      else
      {
         if(read)
         {
            // error occurred, get string message
            e = new Exception(
               "Could not read from socket.", SOCKET_EXCEPTION_TYPE);
            e->getDetails()["error"] = strerror(errno);
         }
         else
         {
            // error occurred, get string message
            e = new Exception(
               "Could not write to socket.", SOCKET_EXCEPTION_TYPE);
            e->getDetails()["error"] = strerror(errno);
         }

         // clear file descriptor and close if its bad
         if(errno == EBADF)
         {
            mFileDescriptor = -1;
            close();
         }
      }
   }
   else if(error == 0)
   {
      if(read)
      {
         // read timeout occurred
         e = new Exception(
            "Socket read timed out.", SOCKET_TIMEOUT_EXCEPTION_TYPE);
         e->getDetails()["error"] = strerror(errno);
      }
      else
      {
         // write timeout occurred
         e = new Exception(
            "Socket write timed out.", SOCKET_TIMEOUT_EXCEPTION_TYPE);
         e->getDetails()["error"] = strerror(errno);
      }
   }
   else
   {
      // get the last error on the socket
      int lastError;
      socklen_t lastErrorLength = sizeof(lastError);
      getsockopt(
         mFileDescriptor, SOL_SOCKET, SO_ERROR,
         (char*)&lastError, &lastErrorLength);
      if(lastError != 0 && lastError != EINPROGRESS)
      {
         if(read)
         {
            // error occurred, get string message
            e = new Exception(
               "Could not read from socket.", SOCKET_EXCEPTION_TYPE);
            e->getDetails()["error"] = strerror(lastError);
         }
         else
         {
            // error occurred, get string message
            e = new Exception(
               "Could not write to socket.", SOCKET_EXCEPTION_TYPE);
            e->getDetails()["error"] = strerror(lastError);
         }
      }
   }

   if(e != NULL)
   {
      ExceptionRef ref = e;
      Exception::set(ref);
   }

//.........这里部分代码省略.........
开发者ID:zengyuxing007,项目名称:monarch,代码行数:101,代码来源:AbstractSocket.cpp


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