本文整理汇总了C++中CError类的典型用法代码示例。如果您正苦于以下问题:C++ CError类的具体用法?C++ CError怎么用?C++ CError使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CError类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: generatePIUID
CPMALError CPIM::generatePIUID(iviLink::CUid const& profileUid,
iviLink::Service::Uid const& serviceUID,
iviLink::Profile::IUid & piuid)
{
bool remote = false;
mIncomingPrfMapMutex.lock();
{
if (!mIncomingPrfMap.empty())
{
tIncomingPrfMap::iterator it = mIncomingPrfMap.find(std::make_pair(serviceUID, profileUid));
if (it != mIncomingPrfMap.end())
{
piuid = it->second;
mIncomingPrfMap.erase(it);
remote = true;
}
}
}
mIncomingPrfMapMutex.unlock();
if (remote)
return CPMALError::NoPMALError(gModuleName);
CError err = PIM::getPIUID(piuid);
if (!err.isNoError())
{
LOG4CPLUS_ERROR(logger, static_cast<std::string>(err));
return CPMALError(CPMALError::ERROR_PIM_INTERNAL, gModuleName, "no piuid");
}
return CPMALError::NoPMALError(gModuleName);
}
示例2: SHBrowseForFolder
BOOL CFolderDialog::DoModal(HWND hWnd, LPCTSTR lpszTitle, LPTSTR pDir)
{
BROWSEINFO bi = {};
bi.hwndOwner = hWnd;
bi.lpfn = reinterpret_cast<BFFCALLBACK>(BrowseCallBackProc);
bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_USENEWUI;
bi.lParam = reinterpret_cast<LPARAM>(pDir);
bi.lpszTitle = lpszTitle;
LPITEMIDLIST pItemID = SHBrowseForFolder(&bi);
if (pItemID == nullptr)
return FALSE;
LPMALLOC pMalloc = nullptr;
if (SHGetMalloc(&pMalloc) == E_FAIL)
{
CError error;
error.Message(hWnd, _T("SHGetMalloc Error"));
return FALSE;
}
SHGetPathFromIDList(pItemID, pDir);
pMalloc->Free(pItemID);
pMalloc->Release();
return TRUE;
}
示例3: LOG4CPLUS_TRACE_METHOD
void CPIM::unloadAll()
{
LOG4CPLUS_TRACE_METHOD(logger, __PRETTY_FUNCTION__);
typedef PIM::CProfileInstanceMap::tProfilesList PL;
PL profiles;
CError err = mInstanceMap.getAllRegisterd(profiles);
if (!err.isNoError())
{
LOG4CPLUS_ERROR(logger, static_cast<std::string>(err));
return;
}
IProfileManagerCallbacks* clbs = NULL;
CPMALComponentMgr* mgr = CPMALComponentMgr::getInstance();
if (mgr)
{
clbs = mgr->getProfileManagerCallbacks();
}
for (PL::iterator it = profiles.begin(); it != profiles.end(); ++it)
{
Profile::IUid const& piuid = it->first;
Profile::CProfile* pp = static_cast<Profile::CProfile*>(it->second);
unloadProfileThroughClient(clbs, pp, piuid);
}
}
示例4: CError
// ** When an exception is thrown, execution of the current function is stopped and
// jumps directly to the catch block of the innermost exception frame. The
// exception mechanism bypasses the normal exit path from a function. Therefore,
// you must be sure to delete those memory blocks that would be deleted in a
// normal exit.
// static
void Library::ThrowAssertion(LPCSTR lpszFilename, int nLine,
LPCSTR lpszExpression, LPCSTR lpszError/*=NULL*/)
{
// CAppException* pe = new CAppException(TRUE); // pass true if creating on the heap
// Bug: can't just copy LPCTSTR pointer to string, because it might be a temporary object.
// The error message was getting overwritten with FE EE's and didn't know what was going on -
// a CString was being passed here and then going out of scope because of the throw -
// so use strcpy or CStrings
// pe->m_pszError = pszError; // store error message
// pe->m_strError = "Assertion Failed";
// throw pe;
// CError e(_T("Assertion Failed"), TRUE);
// e.SetFileLocation(lpszFilename, nLine, lpszExpression);
// HandleError(e);
// CError e(FALSE); // false because created on the stack
// e.SetName(_T("Assertion Failed"));
// e.SetSeverity(TRUE);
// e.SetFileLocation(lpszFilename, nLine, lpszExpression);
// throw &e;
CError* pe = new CError(TRUE);
if (lpszError==NULL)
pe->SetName(_T("Assertion Failed"));
else
pe->SetName(lpszError);
pe->SetSeverity(TRUE);
pe->SetFileLocation(lpszFilename, nLine, lpszExpression);
throw pe;
}
示例5: InitModule
void InitModule()
{
g_pErrorCS = NULL;
g_pModulesCS = NULL;
g_pModules = NULL;
g_pLocModules = NULL;
g_pLocDlls = NULL;
g_pNoMemoryError = NULL;
;
::KLSTD_CreateCriticalSection(&g_pModulesCS);
g_pErrorCS = g_pModulesCS;
;
g_pModules = new modules_t(c_nModulesHashSize);
g_pLocModules = new modules_t(c_nModulesHashSize);
g_pLocDlls = new map_locmodules_t(c_nModulesHashSize);
;
{
KLSTD::CAutoPtr<Error> pError;
CError* p = NULL;
pError.Attach(p = new RcClassImpl<CError>);
if(p)
{
p->Initialize(
0,
L"KLSTD",
STDE_NOMEMORY,
NULL,
0,
L"Out Of memory",
true);
g_pNoMemoryError = pError;
};
};
};
示例6: LOG4CPLUS_TRACE_METHOD
void CMediaControlServerProfile::onDisable() {
LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__);
CError err = iviLink::Channel::deallocateChannel(mChannelID);
if (!err.isNoError()) {
LOG4CPLUS_WARN(msLogger, "Unable to deallocate channel: " + static_cast<std::string> (err));
}
}
示例7: make_tuple
std::tuple<OrmId_t, Orm_t> COrmManager::Create(
HandleId_t handleid, const char *table,
CError<COrm> &error)
{
static const std::tuple<OrmId_t, Orm_t> empty_ret(0, nullptr);
if (CHandleManager::Get()->IsValidHandle(handleid) == false)
{
error.set(COrm::Error::INVALID_CONNECTION_HANDLE, "invalid connection handle");
return empty_ret;
}
if (table == nullptr || strlen(table) == 0)
{
error.set(COrm::Error::EMPTY_TABLE, "empty table name");
return empty_ret;
}
OrmId_t id = 1;
while (m_Instances.find(id) != m_Instances.end())
++id;
return std::make_tuple(id, std::make_shared<COrm>(handleid, table));
}
示例8: CreateFileMapping
LPVOID CFileMap::Open(HANDLE hFile, DWORD Mode)
{
// Create a file mapping object.
if (Mode == FILE_READ)
m_hFileMap = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
else if (Mode == FILE_WRITE)
m_hFileMap = CreateFileMapping(hFile, NULL, PAGE_READWRITE, 0, 0, NULL);
if (m_hFileMap == INVALID_HANDLE_VALUE)
{
CError error;
error.Message(GetForegroundWindow(), _T("File mapping error."));
return NULL;
}
// Get start address of the map view.
if (Mode == FILE_READ)
m_lpFileMapBase = MapViewOfFile(m_hFileMap, FILE_MAP_READ, 0, 0, 0);
else if (Mode == FILE_WRITE)
m_lpFileMapBase = MapViewOfFile(m_hFileMap, FILE_MAP_WRITE, 0, 0, 0);
if (m_lpFileMapBase == NULL)
{
CError error;
error.Message(GetForegroundWindow(), _T("File mapping error."));
return NULL;
}
m_lpFileMap = m_lpFileMapBase;
return m_lpFileMapBase;
}
示例9: CThread
CConnectivityAgentProxy::CConnectivityAgentProxy()
: CThread("CallbackTread"), mpIpc(NULL)
{
LOG4CPLUS_TRACE_METHOD(logger, __PRETTY_FUNCTION__);
static char const* const arr[] =
{ gpCA_UNIX_SOCK_PATH, first_lsn_path, second_lsn_path };
for (size_t i = 0; i < sizeof(arr) / sizeof(arr[0]); ++i)
{
if (arr[i])
{
LOG4CPLUS_INFO(logger,
"Trying to connect to connectivity agent using address " + std::string(arr[i]));
CIpc* pipc = new CIpc(arr[i], *this);
CError err = pipc->connect();
if (err.isNoError())
{
mpIpc = pipc;
break;
} else
{
LOG4CPLUS_WARN(logger, static_cast<std::string>(err));
delete pipc;
}
}
}
if (!mpIpc)
{
LOG4CPLUS_ERROR(logger, "Unable to connect to connectivity agent");
}
start();
}
示例10: connect
bool connect()
{
CError err = CError::NoError();
if (mpIpc == NULL)
{
char const * addr;
if (gpNEGOTIATOR_IPC_ADDR != NULL)
{
addr = gpNEGOTIATOR_IPC_ADDR;
} else
{
addr = ipcNegotiatorId;
}
mpIpc = new CIpc(addr, *this);
}
for (int tryNum = 1; tryNum <= MAX_TRY_COUNT; ++tryNum)
{
err = mpIpc->connect();
if (err.isNoError())
{
return true;
}
sleep(2);
}
return false;
}
示例11: loop
int CProfileRepoServerClb::loop()
{
CError err = CError::NoError("ProfileRepository","loop");
for (int i = 1; ; ++i)
{
LOG4CPLUS_INFO(msLogger, "CProfileRepoServerClb::loop() : connection try number: "+
convertIntegerToString(i));
err = mpIpc->waitForConnection();
LOG4CPLUS_INFO(msLogger, "CProfileRepoServerClb::loop() : waitForConnectionEnded()");
if (err.isNoError())
{
LOG4CPLUS_INFO(msLogger,"CProfileRepoServerClb::loop() :: *** client connected to server ***");
mConLostSem.wait();
LOG4CPLUS_INFO(msLogger,"CProfileRepoServerClb::loop() :: *** connection lost, exiting ***");
return 0;
}
else
{
LOG4CPLUS_INFO(msLogger, static_cast<std::string>(err));
}
LOG4CPLUS_INFO(msLogger, "failed connection");
usleep (250000);
}
return 0;
}
示例12: LOG4CPLUS_TRACE_METHOD
void CPmpProtocol::connect()
{
LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__ );
while (mBe)
{
LOG4CPLUS_INFO(msLogger, "connect attempt");
UInt32 chid = 0;
CError err = iviLink::ChannelSupervisor::allocateChannel(this,mTag.c_str(), chid);
if (err.isNoError())
{
mChannelIdCond.lock();
LOG4CPLUS_INFO(msLogger, "ok chid = " +
convertIntegerToString(static_cast<int>(chid)));
mChannelId = chid;
mChannelIdCond.broadcast();
mChannelIdCond.unlock();
mConnectionLostSem.wait();
}
else
{
LOG4CPLUS_INFO(msLogger, static_cast<std::string>(err));
sleep(1);
}
}
}
示例13: WriteErrLog
void CErrLogMgr::WriteErrLog(CError& exp)
{
if ( !CatchErrorEnabled() || !ErrLogEnabled() )
{
puts(exp.ErrorTitle());
if( exp.ErrorMsg()[0] )
{
putchar('\t');
puts(exp.ErrorMsg());
putchar('\n');
}
}
else
{
uint64 uCurTime = GetProcessTime();
//如果两次记录log的时间大于interval,我们就要换一个log来记录了
//如果小于这个值,我们仍然使用原来的文件记录
if(uCurTime - m_uLastLogTime > (uint64)m_uInterval)
{
CErrLogThreadMgr::Inst()->AddCloseErrlogJob();
CreateErrLogFile();
}
CErrLogThreadMgr::Inst()->AddWriteErrlogJob(exp,m_strErrInfo.c_str());
m_uLastLogTime = uCurTime;
}
}
示例14: CreateError
KLSTD_NOTHROW KLERR::ErrorPtr CreateError(
const ErrLocAdapt* pLocInfo,
const wchar_t* szwModule,
int nId,
const char* szaFile,
int nLine,
const wchar_t* szwMessage) throw()
{
KLSTD::CAutoPtr<KLERR::Error> pResult;
try
{
CError* p = NULL;
pResult.Attach(p = new CError);
if(p)
{
p->Initialize(0, szwModule, nId, szaFile, nLine, szwMessage);
if(pLocInfo)
p->LocSetInfo(*pLocInfo);
};
}
catch(std::exception& err)
{
KLERR_TRACE_UNEXPECTED();
};
if(!pResult)
pResult = KLERR::g_pNoMemoryError;
if(!pResult)
abort();
return pResult;
};
示例15: LOG4CPLUS_TRACE_METHOD
void CAppManPmpIpcClient::loop()
{
LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__);
mBe = true;
CError err = CError::NoError("","");
for (int i = 1;mBe ; ++i)
{
LOG4CPLUS_INFO(msLogger, "loop() : connect trying number : " + convertIntegerToString(i));
err = mpIpc->connect();
LOG4CPLUS_INFO(msLogger, "loop() : connect ended");
if (mBe && err.isNoError())
{
mNoConnection = false;
mConLostSem.wait();
mNoConnection = true;
}
if (!mBe)
{
LOG4CPLUS_INFO(msLogger, "loop() :: mBe == false");
break;
}
LOG4CPLUS_WARN(msLogger, "loop() :: connection failed");
usleep(250000);
}
}