本文整理汇总了C++中UserException函数的典型用法代码示例。如果您正苦于以下问题:C++ UserException函数的具体用法?C++ UserException怎么用?C++ UserException使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了UserException函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UserException
void SyncClusterConnection::say( Message &toSend ) {
string errmsg;
if ( ! prepare( errmsg ) )
throw UserException( 13397 , (string)"SyncClusterConnection::say prepare failed: " + errmsg );
for ( size_t i=0; i<_conns.size(); i++ ) {
_conns[i]->say( toSend );
}
_checkLast();
}
示例2: keyAt
virtual BSONObj keyAt(const IndexCatalogEntry* btreeState,
DiskLoc bucket, int keyOffset) const {
verify(!bucket.isNull());
const BtreeBucket<Version> *b = getBucket(btreeState,bucket);
int n = b->getN();
if (n == b->INVALID_N_SENTINEL) {
throw UserException(deletedBucketCode, "keyAt bucket deleted");
}
dassert( n >= 0 && n < 10000 );
return keyOffset >= n ? BSONObj() : b->keyNode(keyOffset).key.toBson();
}
示例3: UserException
Chunk& ChunkManager::findChunk( const BSONObj & obj ){
for ( vector<Chunk*>::iterator i=_chunks.begin(); i != _chunks.end(); i++ ){
Chunk * c = *i;
if ( c->contains( obj ) )
return *c;
}
stringstream ss;
ss << "couldn't find a chunk which should be impossible extracted: " << _key.extractKey( obj );
throw UserException( ss.str() );
}
示例4: if
void ClientInfo::newPeerRequest( const HostAndPort& peer ) {
if ( ! _remote.hasPort() )
_remote = peer;
else if ( _remote != peer ) {
stringstream ss;
ss << "remotes don't match old [" << _remote.toString() << "] new [" << peer.toString() << "]";
throw UserException( 13134 , ss.str() );
}
newRequest();
}
示例5: AddData
void AddData(ofstream & r, int i){
try{
string resFileName = "staged_scheme_" + to_string((long long)i) + ".txt";
ifstream res(resFileName);
if (res.fail()) throw UserException("AddData(): unable to open res file");
string s;
while (!res.eof()){
getline(res,s);
r << s << endl;
}
res.close();
if (remove(resFileName.c_str())!=0)
throw UserException("AddData: unable to remove file");
}
catch (UserException& e){
cout<<"error : " << e.what() <<endl;
std::system("pause");
exit(EXIT_FAILURE);
}
}
示例6: UserException
void SyncClusterConnection::remove( const string &ns , Query query, int flags ) {
string errmsg;
if ( ! prepare( errmsg ) )
throw UserException( 8020 , (string)"SyncClusterConnection::remove prepare failed: " + errmsg );
for ( size_t i=0; i<_conns.size(); i++ ) {
_conns[i]->remove( ns , query , flags );
}
_checkLast();
}
示例7: handleIndexWrite
void handleIndexWrite( int op , Request& r ) {
DbMessage& d = r.d();
if ( op == dbInsert ) {
while( d.moreJSObjs() ) {
BSONObj o = d.nextJsObj();
const char * ns = o["ns"].valuestr();
if ( r.getConfig()->isSharded( ns ) ) {
BSONObj newIndexKey = o["key"].embeddedObjectUserCheck();
uassert( 10205 , (string)"can't use unique indexes with sharding ns:" + ns +
" key: " + o["key"].embeddedObjectUserCheck().toString() ,
IndexDetails::isIdIndexPattern( newIndexKey ) ||
! o["unique"].trueValue() ||
r.getConfig()->getChunkManager( ns )->getShardKey().uniqueAllowd( newIndexKey ) );
ChunkManager * cm = r.getConfig()->getChunkManager( ns );
assert( cm );
for ( int i=0; i<cm->numChunks(); i++)
doWrite( op , r , cm->getChunk(i)->getShard() );
}
else {
doWrite( op , r , r.primaryShard() );
}
r.gotInsert();
}
}
else if ( op == dbUpdate ) {
throw UserException( 8050 , "can't update system.indexes" );
}
else if ( op == dbDelete ) {
// TODO
throw UserException( 8051 , "can't delete indexes on sharded collection yet" );
}
else {
log() << "handleIndexWrite invalid write op: " << op << endl;
throw UserException( 8052 , "handleIndexWrite invalid write op" );
}
}
示例8: assert
// Deprecated, will move to the strategy itself
Shard Request::primaryShard() const {
assert( _didInit );
if ( _chunkManager ) {
if ( _chunkManager->numChunks() > 1 )
throw UserException( 8060 , "can't call primaryShard on a sharded collection" );
return _chunkManager->findChunk( _chunkManager->getShardKey().globalMin() )->getShard();
}
Shard s = _config->getShard( getns() );
uassert( 10194 , "can't call primaryShard on a sharded collection!" , s.ok() );
return s;
}
示例9: _insert
void _insert( Request& r , DbMessage& d, ChunkManagerPtr manager ) {
while ( d.moreJSObjs() ) {
BSONObj o = d.nextJsObj();
if ( ! manager->hasShardKey( o ) ) {
bool bad = true;
if ( manager->getShardKey().partOfShardKey( "_id" ) ) {
BSONObjBuilder b;
b.appendOID( "_id" , 0 , true );
b.appendElements( o );
o = b.obj();
bad = ! manager->hasShardKey( o );
}
if ( bad ) {
log() << "tried to insert object without shard key: " << r.getns() << " " << o << endl;
throw UserException( 8011 , "tried to insert object without shard key" );
}
}
// Many operations benefit from having the shard key early in the object
o = manager->getShardKey().moveToFront(o);
const int maxTries = 10;
bool gotThrough = false;
for ( int i=0; i<maxTries; i++ ) {
try {
ChunkPtr c = manager->findChunk( o );
log(4) << " server:" << c->getShard().toString() << " " << o << endl;
insert( c->getShard() , r.getns() , o );
r.gotInsert();
if ( r.getClientInfo()->autoSplitOk() )
c->splitIfShould( o.objsize() );
gotThrough = true;
break;
}
catch ( StaleConfigException& e ) {
log( i < ( maxTries / 2 ) ) << "retrying insert because of StaleConfigException: " << e << " object: " << o << endl;
r.reset();
manager = r.getChunkManager();
uassert(14804, "collection no longer sharded", manager);
}
sleepmillis( i * 200 );
}
assert( inShutdown() || gotThrough );
}
}
示例10: UserException
double Workflow::GetExecTime ( int pNum, int type, int cores) const {
try{
if (pNum < 0 || pNum > packages.size()-1)
throw UserException("Workflow::GetExecTime() error. Wrong packageNum" + to_string(pNum));
return packages[pNum].GetExecTime(type, cores);
}
catch (UserException& e){
std::cout<<"error : " << e.what() <<endl;
std::system("pause");
exit(EXIT_FAILURE);
}
}
示例11: UserException
ChunkManagerPtr DBConfig::shardCollection( const string& ns , ShardKeyPattern fieldsAndOrder , bool unique ){
if ( ! _shardingEnabled )
throw UserException( 8042 , "db doesn't have sharding enabled" );
scoped_lock lk( _lock );
ChunkManagerPtr info = _shards[ns];
if ( info )
return info;
if ( _isSharded( ns ) )
throw UserException( 8043 , "already sharded" );
log() << "enable sharding on: " << ns << " with shard key: " << fieldsAndOrder << endl;
_sharded[ns] = CollectionInfo( fieldsAndOrder , unique );
info.reset( new ChunkManager( this , ns , fieldsAndOrder , unique ) );
_shards[ns] = info;
return info;
}
示例12: assert
void ClusteredCursor::_checkCursor( DBClientCursor * cursor ) {
assert( cursor );
if ( cursor->hasResultFlag( ResultFlag_ShardConfigStale ) ) {
throw StaleConfigException( _ns , "ClusteredCursor::query" );
}
if ( cursor->hasResultFlag( ResultFlag_ErrSet ) ) {
BSONObj o = cursor->next();
throw UserException( o["code"].numberInt() , o["$err"].String() );
}
}
示例13: vishnuScriptGenConvertor
/**
* \brief Function to return the generic script convertor
* \param batchType The type of the batch scheduler
* \param scriptGenContent The content of the script to convert
* \return The generic script convertor
*/
boost::shared_ptr<ScriptGenConvertor>
vishnuScriptGenConvertor(const int batchType,
const std::string& scriptGenContent) {
boost::shared_ptr< ScriptGenConvertor> scriptGenConvertor(new ScriptGenConvertor(batchType, scriptGenContent));
std::string parse_error ;
if (scriptGenConvertor->parseFile(parse_error)==-1) {
std::string errorMessage = "Can't generate this generic script content \n"+parse_error ;
throw UserException(ERRCODE_INVALID_PARAM, errorMessage);
} ;
return scriptGenConvertor;
}
示例14: UserException
void SyncClusterConnection::say( Message &toSend, bool isRetry , string * actualServer ) {
string errmsg;
if ( ! prepare( errmsg ) )
throw UserException( 13397 , (string)"SyncClusterConnection::say prepare failed: " + errmsg );
for ( size_t i=0; i<_conns.size(); i++ ) {
_conns[i]->say( toSend );
}
// TODO: should we set actualServer??
_checkLast();
}
示例15: isNumericalValue
/**
* \brief Function to check the job nbNodesAndCpuPerNode
* \param nbNodesAndNbCpuPerNode the number of nodes and cpu per node
* \return raises an exception on error
*/
void
vishnu::checkJobNbNodesAndNbCpuPerNode(const std::string& nbNodesAndCpuPerNode) {
if(nbNodesAndCpuPerNode.size()!=0) {
size_t posNbNodes;
try {
posNbNodes = nbNodesAndCpuPerNode.find(":");
if(posNbNodes!=std::string::npos) {
std::string nbNodes = nbNodesAndCpuPerNode.substr(0, posNbNodes);
isNumericalValue(nbNodes);
std::string cpuPerNode = nbNodesAndCpuPerNode.substr(posNbNodes+1);
isNumericalValue(cpuPerNode);
} else {
throw UserException(ERRCODE_INVALID_PARAM, ("Invalid NbNodesAndNbCpuPerNode value: "+nbNodesAndCpuPerNode));
}
} catch(UserException& ue) {
throw UserException(ERRCODE_INVALID_PARAM, ("Invalid NbNodesAndNbCpuPerNode value: "+nbNodesAndCpuPerNode));
}
}
}