本文整理汇总了C++中ErrorPtr类的典型用法代码示例。如果您正苦于以下问题:C++ ErrorPtr类的具体用法?C++ ErrorPtr怎么用?C++ ErrorPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ErrorPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: KLERR_throwLocError
KLCSC_DECL KLSTD_NORETURN void KLERR_throwLocError(
const ErrLocAdapt& locinfo,
const wchar_t* szwModule,
int nId,
const char* szaFile,
int nLine,
const wchar_t* szwMessage ...)
{
ErrorPtr pError = CreateError(
&locinfo,
szwModule,
nId,
szaFile,
nLine,
szwMessage);
try
{
va_list lst;
va_start(lst, szwMessage);
pError->SetMessageParams(lst);
va_end(lst);
}
catch(std::exception& err)
{
KLERR_TRACE_UNEXPECTED();
};
throw pError.Detach();
};
示例2: sendError
ErrorPtr JsonRpcComm::sendError(const char *aJsonRpcId, ErrorPtr aErrorToSend)
{
if (!Error::isOK(aErrorToSend)) {
return sendError(aJsonRpcId, (uint32_t)aErrorToSend->getErrorCode(), aErrorToSend->getErrorMessage());
}
return ErrorPtr();
}
示例3: initDiscovery
void initDiscovery()
{
// get discovery params
// - host name
string s;
string hostname;
if (!getStringOption("hostname", hostname)) {
// none specified, create default
hostname = string_format("plan44-vdcd-%s", p44VdcHost->getDsUid().getString().c_str());
}
// start DS advertising if not disabled
if (!getOption("nodiscovery")) {
// start the basic service
ErrorPtr err = DiscoveryManager::sharedDiscoveryManager().start(
hostname.c_str()
);
if (Error::isOK(err)) {
// started ok, set discovery params
int sshPort = 0;
getIntOption("sshport", sshPort);
// start discovery manager
DiscoveryManager::sharedDiscoveryManager().advertiseDS(
p44VdcHost,
getOption("noauto"),
p44VdcHost->webUiPort,
p44VdcHost->webUiPath,
sshPort
);
}
else {
LOG(LOG_ERR, "**** Cannot start discovery manager: %s", err->description().c_str());
}
}
}
示例4: sendError
ErrorPtr VdcApiRequest::sendError(ErrorPtr aErrorToSend)
{
if (!Error::isOK(aErrorToSend)) {
return sendError((uint32_t)aErrorToSend->getErrorCode(), aErrorToSend->getErrorMessage());
}
return ErrorPtr();
}
示例5: transmitString
bool FdComm::transmitString(const string &aString)
{
ErrorPtr err;
size_t res = transmitBytes(aString.length(), (uint8_t *)aString.c_str(), err);
if (!Error::isOK(err)) {
FOCUSLOG("FdComm: Error sending data: %s", err->description().c_str());
}
return Error::isOK(err) && res==aString.length(); // ok if no error and all bytes sent
}
示例6: establishConnection
void SerialComm::reconnectHandler()
{
if (reconnecting) {
ErrorPtr err = establishConnection();
if (!Error::isOK(err)) {
LOG(LOG_ERR, "SerialComm: re-connect failed: %s -> retry again later", err->description().c_str());
reconnecting = true;
MainLoop::currentMainLoop().executeOnce(boost::bind(&SerialComm::reconnectHandler, this), 15*Second);
}
else {
LOG(LOG_NOTICE, "SerialComm: successfully reconnected to %s", connectionPath.c_str());
}
}
}
示例7: sendError
ErrorPtr VdcApiRequest::sendError(ErrorPtr aErrorToSend)
{
if (!Error::isOK(aErrorToSend)) {
VdcApiErrorPtr ve = boost::dynamic_pointer_cast<VdcApiError>(aErrorToSend);
if (ve) {
// special VdcApiError, has extra user facing information
return sendError((uint32_t)aErrorToSend->getErrorCode(), aErrorToSend->getErrorMessage(), ApiValuePtr(), ve->getErrorType(), ve->getUserFacingMessage());
}
else {
return sendError((uint32_t)aErrorToSend->getErrorCode(), aErrorToSend->getErrorMessage());
}
}
return ErrorPtr();
}
示例8: LOG
void DaliDeviceContainer::testRWResponse(CompletedCB aCompletedCB, DaliAddress aShortAddr, uint8_t aTestByte, bool aNoOrTimeout, uint8_t aResponse, ErrorPtr aError)
{
if (Error::isOK(aError) && !aNoOrTimeout && aResponse==aTestByte) {
LOG(LOG_NOTICE," - sent 0x%02X, received 0x%02X\n",aTestByte, aResponse, aNoOrTimeout);
// successfully read back same value from DTR as sent before
// - check if more tests
switch (aTestByte) {
case 0x55: aTestByte = 0xAA; break; // next test: inverse
case 0xAA: aTestByte = 0x00; break; // next test: all 0
case 0x00: aTestByte = 0xFF; break; // next test: all 1
case 0xFF: aTestByte = 0xF0; break; // next test: half / half
case 0xF0: aTestByte = 0x0F; break; // next test: half / half inverse
default:
// all tests done
aCompletedCB(aError);
// turn off lights
daliComm->daliSendDirectPower(DaliBroadcast, 0); // off
return;
}
// launch next test
testRW(aCompletedCB, aShortAddr, aTestByte);
}
else {
// not ok
if (Error::isOK(aError) && aNoOrTimeout) aError = ErrorPtr(new DaliCommError(DaliCommErrorMissingData));
// report
LOG(LOG_ERR,"DALI self test error: sent 0x%02X, error: %s\n",aTestByte, aError->description().c_str());
aCompletedCB(aError);
}
}
示例9: socketStatusHandler
void SsdpSearch::socketStatusHandler(ErrorPtr aError)
{
FOCUSLOG("SSDP socket status: %s", aError ? aError->description().c_str() : "<no error>");
if (Error::isOK(aError)) {
FOCUSLOG("### sending UDP M-SEARCH");
// unregister socket status handler (or we'll get called when connection closes)
setConnectionStatusHandler(NULL);
// send search request
string ssdpSearch = string_format(
"M-SEARCH * HTTP/1.1\n"
"HOST: %s:%s\n"
"MAN: \"ssdp:discover\"\n"
"MX: %d\n"
"ST: %s\n",
SSDP_BROADCAST_ADDR,
SSDP_PORT,
SSDP_MX,
searchTarget.c_str()
);
transmitString(ssdpSearch);
// start timer (wait 1.5 the MX for answers)
timeoutTicket = MainLoop::currentMainLoop().executeOnce(boost::bind(&SsdpSearch::searchTimedOut, this), SSDP_MX*1500*MilliSecond);
}
else {
// error starting search
if (searchResultHandler) {
searchResultHandler(this, aError);
}
}
}
示例10: handleCreateUserAnswer
void handleCreateUserAnswer(JsonObjectPtr aJsonResponse, ErrorPtr aError)
{
if (Error::isOK(aError)) {
FOCUSLOG("Received success answer:\n%s", aJsonResponse->json_c_str());
JsonObjectPtr s = HueComm::getSuccessItem(aJsonResponse);
// apparently successful, extract user name
if (s) {
JsonObjectPtr u = s->get("username");
if (u) {
hueComm.userName = u->stringValue();
hueComm.uuid = currentAuthCandidate->first;
hueComm.baseURL = currentAuthCandidate->second;
hueComm.apiReady = true; // can use API now
FOCUSLOG("hue Bridge %s @ %s: successfully registered as user %s", hueComm.uuid.c_str(), hueComm.baseURL.c_str(), hueComm.userName.c_str());
// successfully registered with hue bridge, let caller know
callback(ErrorPtr());
// done!
keepAlive.reset(); // will delete object if nobody else keeps it
return;
}
}
}
else {
LOG(LOG_ERR, "hue Bridge: Error creating user: %s", aError->description().c_str());
}
// try next
++currentAuthCandidate;
processCurrentAuthCandidate(); // process next, if any
}
示例11: socketError
bool SocketComm::connectionMonitorHandler(MLMicroSeconds aCycleStartTime, int aFd, int aPollFlags)
{
ErrorPtr err;
if ((aPollFlags & POLLOUT) && isConnecting) {
// became writable, check status
err = socketError(aFd);
}
else if (aPollFlags & POLLHUP) {
err = ErrorPtr(new SocketCommError(SocketCommErrorHungUp, "Connection HUP while opening (= connection rejected)"));
}
else if (aPollFlags & POLLERR) {
err = socketError(aFd);
}
// now check if successful
if (Error::isOK(err)) {
// successfully connected
connectionOpen = true;
isConnecting = false;
currentAddressInfo = NULL; // no more addresses to check
freeAddressInfo();
LOG(LOG_DEBUG, "Connection to %s:%s established", hostNameOrAddress.c_str(), serviceOrPortOrSocket.c_str());
// call handler if defined
if (connectionStatusHandler) {
// connection ok
connectionStatusHandler(this, ErrorPtr());
}
// let FdComm base class operate open connection (will install handlers)
setFd(aFd);
}
else {
// this attempt has failed, try next (if any)
LOG(LOG_DEBUG, "- Connection attempt failed: %s", err->description().c_str());
// this will return no error if we have another address to try
err = connectNextAddress();
if (err) {
// no next attempt started, report error
LOG(LOG_WARNING, "Connection to %s:%s failed: %s", hostNameOrAddress.c_str(), serviceOrPortOrSocket.c_str(), err->description().c_str());
if (connectionStatusHandler) {
connectionStatusHandler(this, err);
}
freeAddressInfo();
internalCloseConnection();
}
}
// handled
return true;
}
示例12: keepMyselfAlive
void SocketComm::dataExceptionHandler(int aFd, int aPollFlags)
{
SocketCommPtr keepMyselfAlive(this);
DBGLOG(LOG_DEBUG, "SocketComm::dataExceptionHandler(fd==%d, pollflags==0x%X)", aFd, aPollFlags);
if (!isClosing) {
if (aPollFlags & POLLHUP) {
// other end has closed connection
// - report
if (connectionStatusHandler) {
// report reason for closing
connectionStatusHandler(this, ErrorPtr(new SocketCommError(SocketCommErrorHungUp,"Connection closed (HUP)")));
}
}
else if (aPollFlags & POLLIN) {
// Note: on linux a socket closed server side does not return POLLHUP, but POLLIN with no data
// alerted for read, but nothing to read any more: assume connection closed
ErrorPtr err = socketError(aFd);
if (Error::isOK(err))
err = ErrorPtr(new SocketCommError(SocketCommErrorHungUp,"Connection closed (POLLIN but no data -> interpreted as HUP)"));
DBGLOG(LOG_DEBUG, "Connection to %s:%s has POLLIN but no data; error: %s", hostNameOrAddress.c_str(), serviceOrPortOrSocket.c_str(), err->description().c_str());
// - report
if (connectionStatusHandler) {
// report reason for closing
connectionStatusHandler(this, err);
}
}
else if (aPollFlags & POLLERR) {
// error
ErrorPtr err = socketError(aFd);
LOG(LOG_WARNING, "Connection to %s:%s reported error: %s", hostNameOrAddress.c_str(), serviceOrPortOrSocket.c_str(), err->description().c_str());
// - report
if (connectionStatusHandler) {
// report reason for closing
connectionStatusHandler(this, err);
}
}
else {
// NOP
return;
}
// - shut down (Note: if nobody else retains the connection except the server SocketComm, this will delete the connection)
internalCloseConnection();
}
}
示例13: terminateAppWith
void Application::terminateAppWith(ErrorPtr aError)
{
if (Error::isOK(aError)) {
mainLoop.terminate(EXIT_SUCCESS);
}
else {
LOG(LOG_ERR, "Terminating because of error: %s", aError->description().c_str());
mainLoop.terminate(EXIT_FAILURE);
}
}
示例14: SayFailure
KLSTD_NOTHROW KLCSC_DECL void SayFailure(
int level,
Error* perror,
const wchar_t* module,
const char* file,
int line) throw()
{
int nTraceLevel = 0;
if(KLSTD::IsTraceStarted(&nTraceLevel) && nTraceLevel >= level)
{
try
{
if(!perror)
{
Trace(
level,
KLCS_MODULENAME,
L"Unknown error was caught in module \"%ls\" in file \"%hs\" on line %d\n",
module,
file,
line);
}
else
{
ErrorPtr pError = perror;
for( size_t i = 0; pError; ++i )
{
KLSTD::klwstr_t wstrLoc;
KLERR_LocFormatErrorString(pError, wstrLoc.outref());
Trace(
level,
KLCS_MODULENAME,
L"#%u, Error was caught in module \"%ls\" in file \"%hs\" on line %d."
L" Error params: (%u/0x%X (\"%ls\"), \"%ls\", \"%hs\", %d)\n\tError loc: '%ls'.\n",
(i+1),
module,
file,
line,
pError->GetId(),
pError->GetErrorSubcode(),
pError->GetMsg(),
pError->GetModuleName(),
pError->GetFileName(),
pError->GetLine(),
wstrLoc.c_str());
;
KLERR::ErrorPtr pOldErr = pError;
pError = NULL;
pOldErr->GetError2()->GetPreviousError(&pError);
};
};
}
catch(std::exception& err)
{
KLERR_TRACE_UNEXPECTED();
};
};
};
示例15: LOG
void EnoceanDeviceContainer::handleRadioPacket(Esp3PacketPtr aEsp3PacketPtr, ErrorPtr aError)
{
if (aError) {
LOG(LOG_INFO, "Radio packet error: %s\n", aError->description().c_str());
return;
}
// check learning mode
if (learningMode) {
// no learn/unlearn actions detected so far
// - check if we know that device address already. If so, it is a learn-out
bool learnIn = enoceanDevices.find(aEsp3PacketPtr->radioSender())==enoceanDevices.end();
// now add/remove the device (if the action is a valid learn/unlearn)
// detect implicit (RPS) learn in only with sufficient radio strength (or explicit override of that check),
// explicit ones are always recognized
if (aEsp3PacketPtr->eepHasTeachInfo(disableProximityCheck ? 0 : MIN_LEARN_DBM, false)) {
LOG(LOG_NOTICE, "Received EnOcean learn packet while learn mode enabled: %s\n", aEsp3PacketPtr->description().c_str());
// This is actually a valid learn action
ErrorPtr learnStatus;
if (learnIn) {
// new device learned in, add logical devices for it
int numNewDevices = EnoceanDevice::createDevicesFromEEP(this, aEsp3PacketPtr->radioSender(), aEsp3PacketPtr->eepProfile(), aEsp3PacketPtr->eepManufacturer());
if (numNewDevices>0) {
// successfully learned at least one device
// - update learn status (device learned)
getDeviceContainer().reportLearnEvent(true, ErrorPtr());
}
}
else {
// device learned out, un-pair all logical dS devices it has represented
// but keep dS level config in case it is reconnected
unpairDevicesByAddress(aEsp3PacketPtr->radioSender(), false);
getDeviceContainer().reportLearnEvent(false, ErrorPtr());
}
// - only allow one learn action (to prevent learning out device when
// button is released or other repetition of radio packet)
learningMode = false;
} // learn action
}
else {
// not learning mode, dispatch packet to all devices known for that address
for (EnoceanDeviceMap::iterator pos = enoceanDevices.lower_bound(aEsp3PacketPtr->radioSender()); pos!=enoceanDevices.upper_bound(aEsp3PacketPtr->radioSender()); ++pos) {
if (aEsp3PacketPtr->eepHasTeachInfo(MIN_LEARN_DBM, false) && aEsp3PacketPtr->eepRorg()!=rorg_RPS) {
// learning packet in non-learn mode -> report as non-regular user action, may be attempt to identify a device
// Note: RPS devices are excluded because for these all telegrams are regular regular user actions. signalDeviceUserAction() will be called
// from button
if (getDeviceContainer().signalDeviceUserAction(*(pos->second), false)) {
// consumed for device identification purposes, suppress further processing
break;
}
}
// handle regularily (might be RPS switch which does not have separate learn/action packets
pos->second->handleRadioPacket(aEsp3PacketPtr);
}
}
}