本文整理汇总了C++中ExceptionRef::getType方法的典型用法代码示例。如果您正苦于以下问题:C++ ExceptionRef::getType方法的具体用法?C++ ExceptionRef::getType怎么用?C++ ExceptionRef::getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExceptionRef
的用法示例。
在下文中一共展示了ExceptionRef::getType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _getCauseOfType
// method to optimize deep searches for exception type base names
static ExceptionRef _getCauseOfType(ExceptionRef& e, const char* type, int n)
{
ExceptionRef rval(NULL);
// check this exception's type
if(strncmp(e->getType(), type, n) == 0)
{
rval = e;
}
// check this exception's cause
else if(!e->getCause().isNull())
{
rval = _getCauseOfType(e->getCause(), type, n);
}
return rval;
}
示例2: convertToDynamicObject
DynamicObject Exception::convertToDynamicObject(ExceptionRef& e)
{
DynamicObject dyno;
dyno["message"] = e->getMessage();
dyno["type"] = e->getType();
if(!e->getCause().isNull())
{
dyno["cause"] = convertToDynamicObject(e->getCause());
}
if(!(*e).mDetails->isNull())
{
dyno["details"] = e->getDetails();
}
return dyno;
}
示例3: serviceConnection
//.........这里部分代码省略.........
e->isType("monarch.rt.Interrupted"))
{
// send 503 Service Unavailable
const char* html =
"<html><body><h2>503 Service Unavailable</h2></body></html>";
resHeader->setStatus(503, "Service Unavailable");
resHeader->setField("Content-Type", "text/html");
resHeader->setField("Content-Length", 58);
resHeader->setField("Connection", "close");
if((noerror = response->sendHeader()))
{
ByteArrayInputStream is(html, 58);
noerror = response->sendBody(&is);
}
}
// if the exception was not a socket error then send an internal
// server error response
else if(!e->isType("monarch.net.Socket", true))
{
// send 500 Internal Server Error
const char* html =
"<html><body><h2>500 Internal Server Error</h2></body></html>";
resHeader->setStatus(500, "Internal Server Error");
resHeader->setField("Content-Type", "text/html");
resHeader->setField("Content-Length", 60);
resHeader->setField("Connection", "close");
if((noerror = response->sendHeader()))
{
ByteArrayInputStream is(html, 60);
noerror = response->sendBody(&is);
}
}
else
{
// log socket error
if(e->getDetails()->hasMember("error"))
{
// build error string
string error;
DynamicObjectIterator i =
e->getDetails()["error"].getIterator();
while(i->hasNext())
{
error.append(i->next()->getString());
if(i->hasNext())
{
error.push_back(',');
}
}
MO_CAT_ERROR(MO_HTTP_CAT,
"Connection error: ['%s','%s','%s']",
e->getMessage(), e->getType(), error.c_str());
}
else
{
MO_CAT_ERROR(MO_HTTP_CAT,
"Connection error: ['%s','%s']",
e->getMessage(), e->getType());
}
}
// monitor request error
if(!mConnectionMonitor.isNull())
{
mConnectionMonitor->afterRequestError(
&hc, request, response, e);
}
}
// monitor request
if(!mConnectionMonitor.isNull())
{
mConnectionMonitor->afterRequest(&hc);
}
if(keepAlive && noerror)
{
// set keep-alive timeout (defaults to 5 minutes)
hc.setReadTimeout(1000 * 60 * 5);
// clear request and response header fields
reqHeader->clearFields();
resHeader->clearFields();
resHeader->clearStatus();
}
}
// clean up request and response
delete request;
delete response;
// monitor connection
if(!mConnectionMonitor.isNull())
{
mConnectionMonitor->afterServicingConnection(&hc);
}
// close connection
hc.close();
}