本文整理汇总了C++中TException函数的典型用法代码示例。如果您正苦于以下问题:C++ TException函数的具体用法?C++ TException怎么用?C++ TException使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TException函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadLibrary
//*=================================================================================
//*原型: void TSmartTask::Initialized(LPCTSTR pszFileName)
//*功能: 初始化任务库
//*参数: 略
//*返回: 成功与否
//*说明: 任务处理
//*=================================================================================
void TSmartTask::Initialized(LPCTSTR pszFileName)
{
m_hModule = LoadLibrary(pszFileName);
if( m_hModule == NULL )
throw TException("不能装入任务管理动态库!", GetLastError());
InitTaskDLL = (lpfnInitTaskDLL)GetProcAddress(m_hModule, "InitTaskDLL");
DestoryTaskDLL = (lpfnDestoryTaskDLL)GetProcAddress(m_hModule, "DestoryTaskDLL");
ReadTask = (lpfnReadTask)GetProcAddress(m_hModule, "ReadTask");
ReadTSRTask = (lpfnReadTSRTask)GetProcAddress(m_hModule, "ReadTSRTask");
TaskReplace = (lpfnTaskReplace)GetProcAddress(m_hModule, "TaskReplace");
GetTimeOutMap = (lpfnGetTimeOutMap)GetProcAddress(m_hModule, "GetTimeOutMap");
UpdateTask = (lpfnUpdateTask)GetProcAddress(m_hModule, "UpdateTask");
ReadSmartDocInfo = (lpfnReadSmartDocInfo)GetProcAddress(m_hModule, "ReadSmartDocInfo");
ReleaseSmartDoc = (lpfnReleaseSmartDoc)GetProcAddress(m_hModule, "ReleaseSmartDoc");
if( !InitTaskDLL || !DestoryTaskDLL || !ReadTask ||
!ReadTSRTask || !TaskReplace || !GetTimeOutMap || !UpdateTask ||
!ReadSmartDocInfo || !ReleaseSmartDoc )
{
FreeLibrary(m_hModule);
m_hModule = NULL ;
throw TException("不是合法的任务管理动态库!");
}
if( InitTaskDLL(&SmartFunction) != RET_OK )
{
FreeLibrary(m_hModule);
m_hModule = NULL ;
throw TException("任务管理动态库初始化错误!");
}
}
示例2: cob_
void TEvhttpClientChannel::finish(struct evhttp_request* req) {
if (req == NULL) {
try {
cob_();
} catch (const TTransportException& e) {
if (e.getType() == TTransportException::END_OF_FILE)
throw TException("connect failed");
else
throw;
}
return;
} else if (req->response_code != 200) {
try {
cob_();
} catch (const TTransportException& e) {
std::stringstream ss;
ss << "server returned code " << req->response_code;
if (req->response_code_line)
ss << ": " << req->response_code_line;
if (e.getType() == TTransportException::END_OF_FILE)
throw TException(ss.str());
else
throw;
}
return;
}
recvBuf_->resetBuffer(EVBUFFER_DATA(req->input_buffer),
static_cast<uint32_t>(EVBUFFER_LENGTH(req->input_buffer)));
cob_();
return;
}
示例3: OpenSCManager
//*=================================================================================
//*原型: void TServer::DeleteService(LPCTSTR pszServiceName)
//*功能: 删除服务
//*参数: pszServiceName -- 服务名称
//*返回: 无
//*说明: WINNT服务器基类
//*=================================================================================
void TServer::DeleteService(LPCTSTR pszServiceName)
{
SC_HANDLE schSCManager;
schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
if( schSCManager == NULL )
{
throw TException("Call OpenSCManager() Faild!",
GetLastError());
}
SC_HANDLE schService = OpenService(schSCManager, pszServiceName, DELETE);
if( schService == NULL )
{
CloseServiceHandle(schSCManager);
throw TException("服务器还没有安装!");
}
if( !::DeleteService(schService) )
{
CloseServiceHandle(schService);
CloseServiceHandle(schSCManager);
throw TException("删除服务器失败!",
GetLastError());
}
TCHAR szModuleName[MAX_PATH];
wsprintf(szModuleName, "删除服务%s成功!", pszServiceName);
MessageBox(NULL, szModuleName, SERVICE_TITLE, MB_OK|MB_ICONINFORMATION);
CloseServiceHandle(schService);
CloseServiceHandle(schSCManager);
return ;
}
示例4: LoadLibrary
//*==================================================================
//*原型: void TSmartModule::Initialized(LPCTSTR pszFileName)
//*功能: 初始化SmartModule
//*参数: 略
//*返回: 无
//*说明: 业务功能插件
//*==================================================================
void TSmartModule::Initialized(LPCTSTR pszFileName)
{
m_hModule = LoadLibrary(pszFileName);
if( m_hModule == NULL )
{
TCHAR szText[384];
delete this;
wsprintf(szText, "不能装入业务功能动态库%s!", pszFileName);
throw TException(szText, GetLastError());
}
m_InitModuleDLL = (lpfnInitModule)GetProcAddress(m_hModule, "InitModuleDLL");
m_DestoryModuleDLL = (lpfnDestoryModule)GetProcAddress(m_hModule, "DestoryModuleDLL");
m_CreateTaskBuffer = (lpfnCreateTaskBuffer)GetProcAddress(m_hModule, "CreateTaskBuffer");
m_SmartTaskProcess = (lpfnSmartTaskProcess)GetProcAddress(m_hModule, "SmartTaskProcess");
if( !m_InitModuleDLL || !m_DestoryModuleDLL ||
!m_CreateTaskBuffer || !m_SmartTaskProcess )
{
throw TException("非法的业务功能动态库!");
}
long nFlag = 0 ;
if( m_InitModuleDLL(&SmartFunction, &m_Support) != RET_OK )
{
throw TException("业务功能动态库初始化失败!");
}
if( m_Support.nTaskCount <= 0 )
{
throw TException("非法的业务功能动态库!");
}
}
示例5: processor_
TEvhttpServer::TEvhttpServer(boost::shared_ptr<TAsyncBufferProcessor> processor, int port)
: processor_(processor), eb_(NULL), eh_(NULL) {
// Create event_base and evhttp.
eb_ = event_base_new();
if (eb_ == NULL) {
throw TException("event_base_new failed");
}
eh_ = evhttp_new(eb_);
if (eh_ == NULL) {
event_base_free(eb_);
throw TException("evhttp_new failed");
}
// Bind to port.
int ret = evhttp_bind_socket(eh_, NULL, port);
if (ret < 0) {
evhttp_free(eh_);
event_base_free(eb_);
throw TException("evhttp_bind_socket failed");
}
// Register a handler. If you use the other constructor,
// you will want to do this yourself.
// Don't forget to unregister before destorying this TEvhttpServer.
evhttp_set_cb(eh_, "/", request, (void*)this);
}
示例6: defined
//---------------------------------------------------------------------------
int TExecuteProgram::execute(){
double returnValue=0.0;
try{
#if defined (__GNUC__) || (__clang__)
// here should be a test if the file exists.....
int pid, status;
pid = fork();
if (pid == -1)
throw TException("Calling program '" + myExe + "': not able to create fork!", _FATAL_ERROR);
if (pid == 0) execv(myParameter[0], myParameter);
// wait that the process terminates
if (wait (&status) != pid) {
throw TException("Error when executing '" + myExe +"'!", _FATAL_ERROR);
}
if (WIFEXITED (status)) {
returnValue=WEXITSTATUS(status);
} else {
returnValue=0;
}
#elif defined (_MSC_VER)
returnValue=spawnv(P_WAIT, myParameter[0], myParameter);
if(returnValue==-1)
throw TException("Error when executing '" + myExe +"'!" + myExe + "'!", _FATAL_ERROR);
#endif
}
catch(TException error){
throw;
}
catch (...){
throw TException("Error when executing '" + myExe +"'!", _FATAL_ERROR);
}
return returnValue;
} // executeProgram
示例7: m_name
TTimer::Imp::Imp(std::string name, UINT timerRes, TTimer::Type type,
TTimer *timer)
: m_name(name)
, m_timerRes(timerRes)
, m_timer(timer)
, m_type(type)
, m_timerID(NULL)
, m_ticks(0)
, m_delay(0)
, m_started(false)
, m_action(0) {
TIMECAPS tc;
if (timeGetDevCaps(&tc, sizeof(TIMECAPS)) != TIMERR_NOERROR) {
throw TException("Unable to create timer");
}
m_timerRes = std::min((int)std::max((int)tc.wPeriodMin, (int)m_timerRes),
(int)tc.wPeriodMax);
timeBeginPeriod(m_timerRes);
switch (type) {
case TTimer::OneShot:
m_type = TIME_ONESHOT;
break;
case TTimer::Periodic:
m_type = TIME_PERIODIC;
break;
default:
throw TException("Unexpected timer type");
break;
}
}
示例8: THRIFT_FCNTL
/**
* Takes a socket created by listenSocket() and sets various options on it
* to prepare for use in the server.
*/
void TNonblockingServer::listenSocket(THRIFT_SOCKET s) {
// Set socket to nonblocking mode
int flags;
if ((flags = THRIFT_FCNTL(s, THRIFT_F_GETFL, 0)) < 0
|| THRIFT_FCNTL(s, THRIFT_F_SETFL, flags | THRIFT_O_NONBLOCK) < 0) {
::THRIFT_CLOSESOCKET(s);
throw TException("TNonblockingServer::serve() THRIFT_O_NONBLOCK");
}
int one = 1;
struct linger ling = {0, 0};
// Keepalive to ensure full result flushing
setsockopt(s, SOL_SOCKET, SO_KEEPALIVE, const_cast_sockopt(&one), sizeof(one));
// Turn linger off to avoid hung sockets
setsockopt(s, SOL_SOCKET, SO_LINGER, const_cast_sockopt(&ling), sizeof(ling));
// Set TCP nodelay if available, MAC OS X Hack
// See http://lists.danga.com/pipermail/memcached/2005-March/001240.html
#ifndef TCP_NOPUSH
setsockopt(s, IPPROTO_TCP, TCP_NODELAY, const_cast_sockopt(&one), sizeof(one));
#endif
#ifdef TCP_LOW_MIN_RTO
if (TSocket::getUseLowMinRto()) {
setsockopt(s, IPPROTO_TCP, TCP_LOW_MIN_RTO, const_cast_sockopt(&one), sizeof(one));
}
#endif
if (listen(s, LISTEN_BACKLOG) == -1) {
::THRIFT_CLOSESOCKET(s);
throw TException("TNonblockingServer::serve() listen");
}
// Cool, this socket is good to go, set it as the serverSocket_
serverSocket_ = s;
if (!port_) {
struct sockaddr_storage addr;
socklen_t size = sizeof(addr);
if (!getsockname(serverSocket_, reinterpret_cast<sockaddr*>(&addr), &size)) {
if (addr.ss_family == AF_INET6) {
const struct sockaddr_in6* sin = reinterpret_cast<const struct sockaddr_in6*>(&addr);
listenPort_ = ntohs(sin->sin6_port);
} else {
const struct sockaddr_in* sin = reinterpret_cast<const struct sockaddr_in*>(&addr);
listenPort_ = ntohs(sin->sin_port);
}
} else {
GlobalOutput.perror("TNonblocking: failed to get listen port: ", THRIFT_GET_SOCKET_ERROR);
}
}
}
示例9: start
void start(UINT delay) {
if (m_started) throw TException("The timer is already started");
m_timerID = timeSetEvent(delay, m_timerRes, (LPTIMECALLBACK)ElapsedTimeCB,
(DWORD)this, m_type | TIME_CALLBACK_FUNCTION);
m_delay = delay;
m_ticks = 0;
if (m_timerID == NULL) throw TException("Unable to start timer");
m_started = true;
}
示例10: lstrcpy
//*=================================================================================
//*原型: void TServer::CheckInstance()
//*功能: 检测是否有本程序的副本在运行
//*参数: 无
//*返回: 无
//*说明: Windows NT服务器封装基类
//*=================================================================================
void TServer::CheckInstance()
{
TCHAR szMutexName[MAX_PATH];
lstrcpy(szMutexName, _T("__SMART_CARD_SERVICE_RUNNING__"));
m_hInstance = CreateMutex(NULL, TRUE, szMutexName);
if( m_hInstance == NULL )
{
throw TException("程序已经运行!");
}
else if( m_hInstance != NULL && GetLastError() == ERROR_ALREADY_EXISTS )
{
throw TException("程序已经运行!");
}
}
示例11: sprintf
int StatDataEvent::GetCycle()
{
static int iPreBillingCycleID=0;
static int iResult;
BillingCycleMgr billing_cycle_mgr;
BillingCycle * pBillingCycle;
char sTemp[7];
if ( iPreBillingCycleID==pRead->Get_BILLING_CYCLE_ID() )
return iResult;
else
iPreBillingCycleID= pRead->Get_BILLING_CYCLE_ID();
pBillingCycle=billing_cycle_mgr.getBillingCycle(pRead->Get_BILLING_CYCLE_ID());
if ( !pBillingCycle ){
char sTemp[200];
sprintf(sTemp,"[%s:%d] billing_id=[%d]找不到!",__FILE__,__LINE__,(int )pRead->Get_BILLING_CYCLE_ID());
throw TException(sTemp);
}
strncpy(sTemp,pBillingCycle->getEndDate(),6);
sTemp[6]='\0';
iResult=atoi(sTemp);
return iResult;
}
示例12: TException
void TRop::blur(const TRasterP &dstRas, const TRasterP &srcRas, double blur,
int dx, int dy, bool useSSE) {
TRaster32P dstRas32 = dstRas;
TRaster32P srcRas32 = srcRas;
if (dstRas32 && srcRas32)
doBlurRgb<TPixel32, UCHAR, float>(dstRas32, srcRas32, blur, dx, dy, useSSE);
else {
TRaster64P dstRas64 = dstRas;
TRaster64P srcRas64 = srcRas;
if (dstRas64 && srcRas64)
doBlurRgb<TPixel64, USHORT, double>(dstRas64, srcRas64, blur, dx, dy,
useSSE);
else {
TRasterGR8P dstRasGR8 = dstRas;
TRasterGR8P srcRasGR8 = srcRas;
if (dstRasGR8 && srcRasGR8)
doBlurGray<TPixelGR8>(dstRasGR8, srcRasGR8, blur, dx, dy);
else {
TRasterGR16P dstRasGR16 = dstRas;
TRasterGR16P srcRasGR16 = srcRas;
if (dstRasGR16 && srcRasGR16)
doBlurGray<TPixelGR16>(dstRasGR16, srcRasGR16, blur, dx, dy);
else
throw TException("TRop::blur unsupported pixel type");
}
}
}
}
示例13: sprintf
bool StatPayment::GetRecordFromTable(POINT_TYPE &BreakPoint)
{
char sTemp[200];
if ( !pRead){
sprintf(sTemp,"[%s:%d] GetRecordFromTable 游标还没打开!",_FILE_NAME_,__LINE__);
throw TException(sTemp);
}
if ( ! pRead->Next()){
return false;
}
BreakPoint=pRead->Get_PAYMENT_ID();
/*
if (interface.getServ(serv,AcctBalance.Get_SERV_ID(),AcctBalance.Get_STATE_DATE()) ){
pServ=&serv;
pservinfo=serv.getServInfo();
pcustinfo=serv.getCustInfo();
}
else{
pServ=NULL;
pservinfo=NULL;
pcustinfo=NULL;
}
*/
return true;
}
示例14: TestSpawnTeleport
void TestSpawnTeleport() {
std::cout << "TEST EMPTY\n";
TBoard board(8, 8);
TUnit::TSegments segments = {
TSegment(Coords::TColRowPoint(0, 0)),
TSegment(Coords::TColRowPoint(1, 0)),
TSegment(Coords::TColRowPoint(1, 1)),
TSegment(Coords::TColRowPoint(2, 1)),
};
/* xX */
TUnit unit(
TSegment(Coords::TColRowPoint(1, 0)),
std::move(segments)
);
auto teleported = board.TeleportUnitToSpawnPosition(unit);
if (teleported.GetPivot().GetPosition().Column != 4) {
throw TException("TestSpawnTeleport error")
<< __FILE__ << ":" << __LINE__
<< " :\n" << teleported.GetPivot().GetPosition().Column << "\n"
<< "expected: 4"
;
}
}
示例15: TException
bool TBL_BALANCE_PAYOUT_CLASS::Next()
{
if ( m_qry == NULL)
throw TException("mqry not open!");
try{
if ( !m_qry->next())
return false;
item.OPER_PAYOUT_ID=m_qry->field("OPER_PAYOUT_ID").asLong();
item.ACCT_BALANCE_ID=m_qry->field("ACCT_BALANCE_ID").asLong();
item.BILLING_CYCLE_ID=m_qry->field("BILLING_CYCLE_ID").asLong();
item.BILL_ID=m_qry->field("BILL_ID").asLong();
strcpy(item.OPER_TYPE,m_qry->field("OPER_TYPE").asString());
item.STAFF_ID=m_qry->field("STAFF_ID").asLong();
strcpy(item.OPER_DATE,m_qry->field("OPER_DATE").asString());
item.AMOUNT=m_qry->field("AMOUNT").asLong();
item.BALANCE=m_qry->field("BALANCE").asLong();
item.PRN_COUNT=m_qry->field("PRN_COUNT").asLong();
strcpy(item.STATE,m_qry->field("STATE").asString());
strcpy(item.STATE_DATE,m_qry->field("STATE_DATE").asString());
return true;
}
catch (TOCIException &oe) {
cout<<"Error occured ... in TBL_BALANCE_PAYOUT_CLASS.cpp"<<endl;
cout<<oe.getErrMsg()<<endl;
cout<<oe.getErrSrc()<<endl;
throw oe;
}
}