summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorEliot Horowitz <ehorowitz@shopwiki.com>2009-02-20 15:07:52 -0500
committerEliot Horowitz <ehorowitz@shopwiki.com>2009-02-20 15:07:52 -0500
commite470130a5e00f0b4a5ebf995af12cf5322b4ab3a (patch)
treed4415795f0a16cd7966937b90ea93fafc9f8f8a4 /client
parentc97ed5184ba394d911f03fdf00856c029a3b6ba0 (diff)
downloadmongo-e470130a5e00f0b4a5ebf995af12cf5322b4ab3a.tar.gz
open to save to check for error
Diffstat (limited to 'client')
-rw-r--r--client/model.cpp9
-rw-r--r--client/model.h2
2 files changed, 9 insertions, 2 deletions
diff --git a/client/model.cpp b/client/model.cpp
index 2068024445a..abf9b587015 100644
--- a/client/model.cpp
+++ b/client/model.cpp
@@ -36,7 +36,7 @@ namespace mongo {
return true;
}
- void Model::save(){
+ void Model::save( bool check ){
ScopedDbConnection conn( modelServer() );
BSONObjBuilder b;
@@ -67,8 +67,15 @@ namespace mongo {
conn->update( getNS() , q , o );
}
+
+ string errmsg = "";
+ if ( check )
+ errmsg = conn->getLastError();
conn.done();
+
+ if ( check && errmsg.size() )
+ throw UserException( (string)"error on Model::save: " + errmsg );
}
} // namespace mongo
diff --git a/client/model.h b/client/model.h
index eff84807da5..3a7b80d349d 100644
--- a/client/model.h
+++ b/client/model.h
@@ -55,7 +55,7 @@ namespace mongo {
@return true if successful.
*/
bool load(BSONObj& query);
- void save();
+ void save( bool check=false );
private:
BSONObj _id;