diff options
author | Adam Midvidy <amidvidy@gmail.com> | 2015-05-26 18:44:43 -0400 |
---|---|---|
committer | Adam Midvidy <amidvidy@gmail.com> | 2015-06-03 11:13:31 -0400 |
commit | f9685f7f8ed8240e763da406e3e97d94e7a919e6 (patch) | |
tree | f7e285e6eeee694165923116b49880499526ffeb /src/mongo/db/commands.h | |
parent | 49cbe32ebe03e393b1013575adc321759def25c3 (diff) | |
download | mongo-f9685f7f8ed8240e763da406e3e97d94e7a919e6.tar.gz |
SERVER-18664 make commands always return {ok: 0.0, errmsg: ..., code: ...} style responses
Diffstat (limited to 'src/mongo/db/commands.h')
-rw-r--r-- | src/mongo/db/commands.h | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/mongo/db/commands.h b/src/mongo/db/commands.h index 01cbcf9fc9f..f35e3f77dc5 100644 --- a/src/mongo/db/commands.h +++ b/src/mongo/db/commands.h @@ -333,6 +333,27 @@ namespace mutablebson { // Set by command line. Controls whether or not testing-only commands should be available. static int testCommandsEnabled; + /** + * When an assertion is hit during command execution, this method is used to fill the fields + * of the command reply with the information from the error. In addition, information about + * the command is logged. This function does not return anything, because there is typically + * already an active exception when this function is called, so there + * is little that can be done if it fails. + */ + static void generateErrorResponse(OperationContext* txn, + rpc::ReplyBuilderInterface* replyBuilder, + const DBException& exception, + const rpc::RequestInterface& request); + + /** + * Similar to other overloads of generateErrorResponse, but doesn't print any information + * about the specific command being executed. This is neccessary, for example, if there is + * an assertion hit while parsing the command. + */ + static void generateErrorResponse(OperationContext* txn, + rpc::ReplyBuilderInterface* replyBuilder, + const DBException& exception); + private: /** @@ -349,7 +370,7 @@ namespace mutablebson { const BSONObj& cmdObj); }; - bool runCommands(OperationContext* txn, + void runCommands(OperationContext* txn, const rpc::RequestInterface& request, rpc::ReplyBuilderInterface* replyBuilder); |