本文整理汇总了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;
}
示例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;
}
示例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);
}
//.........这里部分代码省略.........