diff options
author | Eliot Horowitz <eliot@10gen.com> | 2009-12-28 17:06:07 -0500 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2009-12-28 17:06:07 -0500 |
commit | fa8961c3e8804a2fd606160d7649e973e906d0b4 (patch) | |
tree | 7b05dab00035f95e55fb131f38a15a06e7281a16 /s | |
parent | a3a0bc64f9082d712d8a0789811257ad45a6cb0b (diff) | |
download | mongo-fa8961c3e8804a2fd606160d7649e973e906d0b4.tar.gz |
Exception classess need codes too SERVER-112
Diffstat (limited to 's')
-rw-r--r-- | s/chunk.cpp | 4 | ||||
-rw-r--r-- | s/config.cpp | 4 | ||||
-rw-r--r-- | s/config.h | 2 | ||||
-rw-r--r-- | s/request.cpp | 2 | ||||
-rw-r--r-- | s/strategy_shard.cpp | 16 | ||||
-rw-r--r-- | s/strategy_single.cpp | 6 |
6 files changed, 18 insertions, 16 deletions
diff --git a/s/chunk.cpp b/s/chunk.cpp index 9b757a77368..47c13e8eac1 100644 --- a/s/chunk.cpp +++ b/s/chunk.cpp @@ -446,7 +446,7 @@ namespace mongo { } stringstream ss; ss << "couldn't find a chunk which should be impossible extracted: " << _key.extractKey( obj ); - throw UserException( ss.str() ); + throw UserException( 8070 , ss.str() ); } Chunk* ChunkManager::findChunkOnServer( const string& server ) const { @@ -544,7 +544,7 @@ namespace mongo { ScopedDbConnection conn( i->first ); BSONObj res; if ( ! setShardVersion( conn.conn() , _ns , 0 , true , res ) ) - throw UserException( (string)"OH KNOW, cleaning up after drop failed: " + res.toString() ); + throw UserException( 8071 , (string)"OH KNOW, cleaning up after drop failed: " + res.toString() ); conn.done(); } diff --git a/s/config.cpp b/s/config.cpp index 18e998739e2..0bfb5a39e0f 100644 --- a/s/config.cpp +++ b/s/config.cpp @@ -58,14 +58,14 @@ namespace mongo { ChunkManager* DBConfig::shardCollection( const string& ns , ShardKeyPattern fieldsAndOrder , bool unique ){ if ( ! _shardingEnabled ) - throw UserException( "db doesn't have sharding enabled" ); + throw UserException( 8042 , "db doesn't have sharding enabled" ); ChunkManager * info = _shards[ns]; if ( info ) return info; if ( isSharded( ns ) ) - throw UserException( "already sharded" ); + throw UserException( 8043 , "already sharded" ); log() << "enable sharding on: " << ns << " with shard key: " << fieldsAndOrder << endl; _sharded[ns] = CollectionInfo( fieldsAndOrder , unique ); diff --git a/s/config.h b/s/config.h index 14d76b71067..16aa67aaddc 100644 --- a/s/config.h +++ b/s/config.h @@ -82,7 +82,7 @@ namespace mongo { string getPrimary(){ if ( _primary.size() == 0 ) - throw UserException( (string)"no primary shard configured for db: " + _name ); + throw UserException( 8041 , (string)"no primary shard configured for db: " + _name ); return _primary; } diff --git a/s/request.cpp b/s/request.cpp index ba48d6bd7af..8bebd64c044 100644 --- a/s/request.cpp +++ b/s/request.cpp @@ -64,7 +64,7 @@ namespace mongo { string Request::singleServerName(){ if ( _chunkManager ){ if ( _chunkManager->numChunks() > 1 ) - throw UserException( "can't call singleServerName on a sharded collection" ); + throw UserException( 8060 , "can't call singleServerName on a sharded collection" ); return _chunkManager->findChunk( _chunkManager->getShardKey().globalMin() ).getShard(); } string s = _config->getShard( getns() ); diff --git a/s/strategy_shard.cpp b/s/strategy_shard.cpp index 9cc29ef7795..3521b5baf42 100644 --- a/s/strategy_shard.cpp +++ b/s/strategy_shard.cpp @@ -7,6 +7,8 @@ #include "../client/connpool.h" #include "../db/commands.h" +// error codes 8010-8040 + namespace mongo { class ShardStrategy : public Strategy { @@ -17,7 +19,7 @@ namespace mongo { log(3) << "shard query: " << q.ns << " " << q.query << endl; if ( q.ntoreturn == 1 && strstr(q.ns, ".$cmd") ) - throw UserException( "something is wrong, shouldn't see a command here" ); + throw UserException( 8010 , "something is wrong, shouldn't see a command here" ); ChunkManager * info = r.getChunkManager(); assert( info ); @@ -111,7 +113,7 @@ namespace mongo { if ( bad ){ log() << "tried to insert object without shard key: " << r.getns() << " " << o << endl; - throw UserException( "tried to insert object without shard key" ); + throw UserException( 8011 , "tried to insert object without shard key" ); } } @@ -140,14 +142,14 @@ namespace mongo { uassert( 10202 , "can't mix multi and upsert and sharding" , ! upsert ); if ( upsert && ! manager->hasShardKey( toupdate ) ) - throw UserException( "can't upsert something without shard key" ); + throw UserException( 8012 , "can't upsert something without shard key" ); bool save = false; if ( ! manager->hasShardKey( query ) ){ if ( multi ){ } else if ( query.nFields() != 1 || strcmp( query.firstElement().fieldName() , "_id" ) ){ - throw UserException( "can't do update with query that doesn't have the shard key" ); + throw UserException( 8013 , "can't do update with query that doesn't have the shard key" ); } else { save = true; @@ -161,7 +163,7 @@ namespace mongo { // TODO: check for $set, etc.. on shard key } else if ( manager->hasShardKey( toupdate ) && manager->getShardKey().compare( query , toupdate ) ){ - throw UserException( "change would move shards!" ); + throw UserException( 8014 , "change would move shards!" ); } } @@ -202,7 +204,7 @@ namespace mongo { } if ( justOne && ! pattern.hasField( "_id" ) ) - throw UserException( "can only delete with a non-shard key pattern if can delete as many as we find" ); + throw UserException( 8015 , "can only delete with a non-shard key pattern if can delete as many as we find" ); set<string> seen; for ( vector<Chunk*>::iterator i=chunks.begin(); i!=chunks.end(); i++){ @@ -233,7 +235,7 @@ namespace mongo { } else { log() << "sharding can't do write op: " << op << endl; - throw UserException( "can't do this write op on sharded collection" ); + throw UserException( 8016 , "can't do this write op on sharded collection" ); } } diff --git a/s/strategy_single.cpp b/s/strategy_single.cpp index c9ab50af34a..e882a913cf5 100644 --- a/s/strategy_single.cpp +++ b/s/strategy_single.cpp @@ -96,15 +96,15 @@ namespace mongo { } } else if ( op == dbUpdate ){ - throw UserException( "can't update system.indexes" ); + throw UserException( 8050 , "can't update system.indexes" ); } else if ( op == dbDelete ){ // TODO - throw UserException( "can't delete indexes on sharded collection yet" ); + throw UserException( 8051 , "can't delete indexes on sharded collection yet" ); } else { log() << "handleIndexWrite invalid write op: " << op << endl; - throw UserException( "handleIndexWrite invalid write op" ); + throw UserException( 8052 , "handleIndexWrite invalid write op" ); } } |