Changeset 3954
- Timestamp:
- Tue Oct 4 12:36:45 2005
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
-
trunk/campsite/implementation/parser/parser/main.cpp
r3952 r3954 186 186 FD_ZERO(&clSet); 187 187 FD_SET((SOCKET)*pcoClSock, &clSet); 188 outbuf coOutBuf((SOCKET)*pcoClSock); 189 sockstream coOs(&coOutBuf); 190 string coErrorMsg; 188 191 MYSQL* pSql = NULL; 189 192 try … … 219 222 #endif 220 223 221 outbuf coOutBuf((SOCKET)*pcoClSock);222 sockstream coOs(&coOutBuf);223 224 pSql = MYSQLConnection(); 224 225 if (pSql == NULL) // unable to connect to server … … 231 232 RunParser(MYSQLConnection(), pcoURL, coRemoteAddress.c_str(), coOs); 232 233 } 233 coOs.flush();234 delete pcoClSock;235 234 } 236 235 catch (RunException& coEx) 237 236 { 238 delete pcoClSock;237 coErrorMsg = coEx.what(); 238 237 #ifdef _DEBUG 239 cerr << "MyThreadRoutine: " << coEx.what() << endl; 238 cerr << "MyThreadRoutine: " << coEx.what() << " (RunException)" << endl; 239 238 #endif 240 239 } 241 240 catch (SocketErrorException& coEx) 242 241 { 243 delete pcoClSock; 242 coErrorMsg = string("There was an error communicating with the template engine: ") 243 + coEx.Message() + "! Please restart the template engine."; 244 244 #ifdef _DEBUG 245 cerr << "MyThreadRoutine: " << coEx.Message() << endl; 245 cerr << "MyThreadRoutine: " << coEx.Message() << " (SocketErrorException)" << endl; 245 245 #endif 246 246 } 247 247 catch (out_of_range& coEx) 248 248 { 249 delete pcoClSock;249 coErrorMsg = string("Internal out of range error: ") + coEx.what(); 249 249 #ifdef _DEBUG 250 cerr << "MyThreadRoutine: " << coEx.what() << endl; 250 cerr << "MyThreadRoutine: " << coEx.what() << " (out_of_range)" << endl; 250 250 #endif 251 251 } 252 252 catch (bad_alloc& coEx) 253 253 { 254 delete pcoClSock;254 coErrorMsg = string("Internal memory allocation error: ") + coEx.what(); 254 254 #ifdef _DEBUG 255 cerr << "MyThreadRoutine: unable to allocate memory: " << coEx.what()<< endl;255 cerr << "MyThreadRoutine: " << coEx.what() << " (bad_alloc)" << endl; 255 255 #endif 256 256 } 257 257 catch (exception& coEx) 258 258 { 259 delete pcoClSock;259 coErrorMsg = string("Internal error: ") + coEx.what(); 259 259 #ifdef _DEBUG 260 cerr << coEx.what()<< endl;260 cerr << "MyThreadRoutine: " << coEx.what() << " (exception)" << endl; 260 260 #endif 261 261 } 262 catch (...) 263 { 264 coErrorMsg = "Unknown internal error"; 265 #ifdef _DEBUG 266 cerr << "MyThreadRoutine: other exception" << endl; 267 #endif 268 } 269 if (coErrorMsg != "") 270 { 271 coOs << "<html><body><font color=red><h2>There were errors!</h2>" << endl 272 << "<pre>" << coErrorMsg << "</pre>" << endl << "</body></html>" << endl; 273 } 274 coOs.flush(); 275 delete pcoClSock; 262 276 return NULL; 263 277 } -
trunk/campsite/implementation/parser/parser/process_req.cpp
r3889 r3954 89 89 bool bDebug = false, bPreview = false, bTechDebug = false; 90 90 char pchBuf[300]; 91 const CPublication* pcoPub = NULL; 92 id_type nIssue = -1; 91 93 pcoCtx->SetIP(htonl(inet_addr(p_pchRemoteIP))); 92 94 if ((coStr = p_pcoURL->getValue(P_IDLANG)) != "") … … 99 101 pcoCtx->SetPublication(atol(coStr.c_str())); 100 102 pcoCtx->SetDefPublication(atol(coStr.c_str())); 103 pcoPub = CPublicationsRegister::getInstance().getPublication(pcoCtx->Publication()); 101 104 } 102 105 if ((coStr = p_pcoURL->getValue(P_NRISSUE)) != "") … … 104 107 pcoCtx->SetIssue(atol(coStr.c_str())); 105 108 pcoCtx->SetDefIssue(atol(coStr.c_str())); 109 nIssue = pcoCtx->Issue(); 106 110 } 107 111 if ((coStr = p_pcoURL->getValue(P_NRSECTION)) != "") … … 360 364 id_type nLanguage = p_pcoURL->getLanguage(); 361 365 id_type nPublication = p_pcoURL->getPublication(); 362 id_type nIssue = p_pcoURL->getIssue();363 366 id_type nSection = p_pcoURL->getSection(); 364 367 id_type nArticle = p_pcoURL->getArticle(); … … 397 400 CParser::setMYSQL(NULL); 398 401 } 402 catch (InvalidValue& rcoEx) 403 { 404 stringstream coStr; 405 if (pcoPub != NULL && nIssue > 0) 406 { 407 coStr << "Please verify if the issue, section and article templates were set for " 408 << "publication " << *(pcoPub->getAliases().begin()) 409 << ", issue number " << nIssue << "."; 410 } 411 else 412 { 413 coStr << "Internal error of invalid value: " << rcoEx.what(); 414 } 415 throw RunException(coStr.str()); 416 } 399 417 catch (ExStat& rcoEx) 400 418 { 401 419 throw RunException("Error loading template file"); 402 return -1;403 420 } 404 421 catch (RunException& rcoEx) 405 422 { 406 423 throw rcoEx; 407 return -1;408 424 } 409 425 catch (ExMutex& rcoEx) 410 426 { 411 427 throw RunException(rcoEx.Message()); 412 return -1;413 428 } 414 429 catch (bad_alloc& rcoEx) 415 430 { 416 throw RunException("bad alloc"); 417 return -1; 431 throw RunException("unable to allocate memory"); 418 432 } 419 433 return 0;