diff options
author | Eliot Horowitz <eliot@10gen.com> | 2009-09-22 10:22:24 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2009-09-22 10:22:24 -0400 |
commit | a78800d5b8b5188b6cdde1ba66d743958975aaa3 (patch) | |
tree | 042920d130015a1f5a9cc27fb4edb6c46eac1d76 /shell/dbshell.cpp | |
parent | 665b1f748332be36432b49103a8bda69576ad99d (diff) | |
download | mongo-a78800d5b8b5188b6cdde1ba66d743958975aaa3.tar.gz |
catch exceptions in shell
Diffstat (limited to 'shell/dbshell.cpp')
-rw-r--r-- | shell/dbshell.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/shell/dbshell.cpp b/shell/dbshell.cpp index 2569da7e01e..5bdcb3afbae 100644 --- a/shell/dbshell.cpp +++ b/shell/dbshell.cpp @@ -432,7 +432,7 @@ int _main(int argc, char* argv[]) { string cmd = line; if ( cmd.find( " " ) > 0 ) cmd = cmd.substr( 0 , cmd.find( " " ) ); - + if ( cmd.find( "\"" ) == string::npos ){ scope->exec( (string)"__iscmd__ = shellHelper[\"" + cmd + "\"];" , "(shellhelp1)" , false , true , true ); if ( scope->getBoolean( "__iscmd__" ) ){ @@ -444,8 +444,13 @@ int _main(int argc, char* argv[]) { } if ( ! wascmd ){ - scope->exec( code.c_str() , "(shell)" , false , true , false ); - scope->exec( "shellPrintHelper( __lastres__ );" , "(shell2)" , true , true , false ); + try { + scope->exec( code.c_str() , "(shell)" , false , true , false ); + scope->exec( "shellPrintHelper( __lastres__ );" , "(shell2)" , true , true , false ); + } + catch ( std::exception& e ){ + cout << "error:" << e.what() << endl; + } } |