summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands/write_commands/batch_executor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/commands/write_commands/batch_executor.cpp')
-rw-r--r--src/mongo/db/commands/write_commands/batch_executor.cpp27
1 files changed, 9 insertions, 18 deletions
diff --git a/src/mongo/db/commands/write_commands/batch_executor.cpp b/src/mongo/db/commands/write_commands/batch_executor.cpp
index b2f8150433c..45187098a75 100644
--- a/src/mongo/db/commands/write_commands/batch_executor.cpp
+++ b/src/mongo/db/commands/write_commands/batch_executor.cpp
@@ -69,28 +69,13 @@ namespace mongo {
static WCErrorDetail* toWriteConcernError( const Status& wcStatus,
const WriteConcernResult& wcResult ) {
- // Error reported is either the errmsg or err from wc
- string errMsg;
- if ( !wcStatus.isOK() )
- errMsg = wcStatus.toString();
- else if ( wcResult.err.size() )
- errMsg = wcResult.err;
-
- if ( errMsg.empty() )
- return NULL;
-
WCErrorDetail* wcError = new WCErrorDetail;
- if ( wcStatus.isOK() )
- wcError->setErrCode( ErrorCodes::WriteConcernFailed );
- else
- wcError->setErrCode( wcStatus.code() );
-
+ wcError->setErrCode( wcStatus.code() );
+ wcError->setErrMessage( wcStatus.reason() );
if ( wcResult.wTimedOut )
wcError->setErrInfo( BSON( "wtimeout" << true ) );
- wcError->setErrMessage( errMsg );
-
return wcError;
}
@@ -118,6 +103,10 @@ namespace mongo {
status = writeConcern.parse( _defaultWriteConcern );
}
+ if ( status.isOK() ) {
+ status = validateWriteConcern( writeConcern );
+ }
+
if ( !status.isOK() ) {
response->setErrCode( status.code() );
response->setErrMessage( status.reason() );
@@ -161,7 +150,9 @@ namespace mongo {
WriteConcernResult res;
status = waitForWriteConcern( writeConcern, _client->getLastOp(), &res );
- wcError.reset( toWriteConcernError( status, res ) );
+ if ( !status.isOK() ) {
+ wcError.reset( toWriteConcernError( status, res ) );
+ }
}
//