summaryrefslogtreecommitdiff
path: root/scripting
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2009-12-28 16:43:43 -0500
committerEliot Horowitz <eliot@10gen.com>2009-12-28 16:43:43 -0500
commit0ab8149a8e9e900b63ee28b9590a249578339376 (patch)
tree564a5c516b7c308964b79ea761e4800efe26d252 /scripting
parent95137f262c2a57831dccf058428a2f64e900496e (diff)
downloadmongo-0ab8149a8e9e900b63ee28b9590a249578339376.tar.gz
uassert/massert take error code SERVER-112
Diffstat (limited to 'scripting')
-rw-r--r--scripting/engine.cpp14
-rw-r--r--scripting/engine_java.h2
-rw-r--r--scripting/engine_spidermonkey.cpp42
-rw-r--r--scripting/engine_v8.cpp10
-rw-r--r--scripting/sm_db.cpp42
5 files changed, 55 insertions, 55 deletions
diff --git a/scripting/engine.cpp b/scripting/engine.cpp
index b7fd209544e..5e3be4ccd89 100644
--- a/scripting/engine.cpp
+++ b/scripting/engine.cpp
@@ -78,14 +78,14 @@ namespace mongo {
stringstream temp;
temp << "can't append type from:";
temp << t;
- uassert( temp.str() , 0 );
+ uassert( 10206 , temp.str() , 0 );
}
}
int Scope::invoke( const char* code , const BSONObj& args, int timeoutMs ){
ScriptingFunction func = createFunction( code );
- uassert( "compile failed" , func );
+ uassert( 10207 , "compile failed" , func );
return invoke( func , args, timeoutMs );
}
@@ -124,7 +124,7 @@ namespace mongo {
}
void Scope::validateObjectIdString( const string &str ) {
- massert ( "invalid object id: length", str.size() == 24 );
+ massert( 10448 , "invalid object id: length", str.size() == 24 );
for ( string::size_type i=0; i<str.size(); i++ ){
char c = str[i];
@@ -133,7 +133,7 @@ namespace mongo {
( c >= 'A' && c <= 'F' ) ){
continue;
}
- massert( "invalid object id: not hex", false );
+ massert( 10430 , "invalid object id: not hex", false );
}
}
@@ -141,7 +141,7 @@ namespace mongo {
if ( _localDBName.size() == 0 ){
if ( ignoreNotConnected )
return;
- uassert( "need to have locallyConnected already" , _localDBName.size() );
+ uassert( 10208 , "need to have locallyConnected already" , _localDBName.size() );
}
if ( _loadedVersion == _lastVersion )
return;
@@ -158,8 +158,8 @@ namespace mongo {
BSONElement n = o["_id"];
BSONElement v = o["value"];
- uassert( "name has to be a string" , n.type() == String );
- uassert( "value has to be set" , v.type() != EOO );
+ uassert( 10209 , "name has to be a string" , n.type() == String );
+ uassert( 10210 , "value has to be set" , v.type() != EOO );
setElement( n.valuestr() , v );
}
diff --git a/scripting/engine_java.h b/scripting/engine_java.h
index b4d71d022b3..ae11cc14f97 100644
--- a/scripting/engine_java.h
+++ b/scripting/engine_java.h
@@ -195,7 +195,7 @@ namespace mongo {
JavaJS->scopeSetString(s,field,val);
}
void setObject(const char *field, const BSONObj& obj , bool readOnly ) {
- uassert( "only readOnly setObject supported in java" , readOnly );
+ uassert( 10211 , "only readOnly setObject supported in java" , readOnly );
JavaJS->scopeSetObject(s,field,&obj);
}
void setBoolean(const char *field, bool val ) {
diff --git a/scripting/engine_spidermonkey.cpp b/scripting/engine_spidermonkey.cpp
index 62cc0e1ec06..29c718f9d30 100644
--- a/scripting/engine_spidermonkey.cpp
+++ b/scripting/engine_spidermonkey.cpp
@@ -61,7 +61,7 @@ namespace mongo {
}
void check(){
- uassert( "holder magic value is wrong" , _magic == 17 && _obj.isValid() );
+ uassert( 10212 , "holder magic value is wrong" , _magic == 17 && _obj.isValid() );
}
BSONFieldIterator * it();
@@ -144,7 +144,7 @@ namespace mongo {
free( dst );
if ( !JS_CStringsAreUTF8() )
for( string::const_iterator i = ss.begin(); i != ss.end(); ++i )
- uassert( "non ascii character detected", (unsigned char)(*i) <= 127 );
+ uassert( 10213 , "non ascii character detected", (unsigned char)(*i) <= 127 );
return ss;
}
@@ -154,7 +154,7 @@ namespace mongo {
double toNumber( jsval v ){
double d;
- uassert( "not a number" , JS_ValueToNumber( _context , v , &d ) );
+ uassert( 10214 , "not a number" , JS_ValueToNumber( _context , v , &d ) );
return d;
}
@@ -228,7 +228,7 @@ namespace mongo {
JSVAL_IS_VOID( v ) )
return BSONObj();
- uassert( "not an object" , JSVAL_IS_OBJECT( v ) );
+ uassert( 10215 , "not an object" , JSVAL_IS_OBJECT( v ) );
return toObject( JSVAL_TO_OBJECT( v ) );
}
@@ -237,7 +237,7 @@ namespace mongo {
}
string getFunctionCode( jsval v ){
- uassert( "not a function" , JS_TypeOfValue( _context , v ) == JSTYPE_FUNCTION );
+ uassert( 10216 , "not a function" , JS_TypeOfValue( _context , v ) == JSTYPE_FUNCTION );
return getFunctionCode( JS_ValueToFunction( _context , v ) );
}
@@ -294,7 +294,7 @@ namespace mongo {
break;
}
- default: uassert( (string)"can't append field. name:" + name + " type: " + typeString( val ) , 0 );
+ default: uassert( 10217 , (string)"can't append field. name:" + name + " type: " + typeString( val ) , 0 );
}
}
@@ -575,7 +575,7 @@ namespace mongo {
}
cout << "toval: unknown type: " << e.type() << endl;
- uassert( "not done: toval" , 0 );
+ uassert( 10218 , "not done: toval" , 0 );
return 0;
}
@@ -602,7 +602,7 @@ namespace mongo {
}
jsval getProperty( JSObject * o , const char * field ){
- uassert( "object passed to getPropery is null" , o );
+ uassert( 10219 , "object passed to getPropery is null" , o );
jsval v;
assert( JS_GetProperty( _context , o , field , &v ) );
return v;
@@ -693,7 +693,7 @@ namespace mongo {
return JS_TRUE;
}
- uassert( "don't know what to do with this op" , 0 );
+ uassert( 10220 , "don't know what to do with this op" , 0 );
return JS_FALSE;
}
@@ -916,7 +916,7 @@ namespace mongo {
#endif
_runtime = JS_NewRuntime(8L * 1024L * 1024L);
- uassert( "JS_NewRuntime failed" , _runtime );
+ uassert( 10221 , "JS_NewRuntime failed" , _runtime );
if ( ! utf8Ok() ){
log() << "*** warning: spider monkey build without utf8 support. consider rebuilding with utf8 support" << endl;
@@ -924,7 +924,7 @@ namespace mongo {
int x = 0;
assert( x = 1 );
- uassert( "assert not being executed" , x == 1 );
+ uassert( 10222 , "assert not being executed" , x == 1 );
}
~SMEngine(){
@@ -975,16 +975,16 @@ namespace mongo {
smlock;
_context = JS_NewContext( globalSMEngine->_runtime , 8192 );
_convertor = new Convertor( _context );
- massert( "JS_NewContext failed" , _context );
+ massert( 10431 , "JS_NewContext failed" , _context );
JS_SetOptions( _context , JSOPTION_VAROBJFIX);
//JS_SetVersion( _context , JSVERSION_LATEST); TODO
JS_SetErrorReporter( _context , errorReporter );
_global = JS_NewObject( _context , &global_class, NULL, NULL);
- massert( "JS_NewObject failed for global" , _global );
+ massert( 10432 , "JS_NewObject failed for global" , _global );
JS_SetGlobalObject( _context , _global );
- massert( "js init failed" , JS_InitStandardClasses( _context , _global ) );
+ massert( 10433 , "js init failed" , JS_InitStandardClasses( _context , _global ) );
JS_SetOptions( _context , JS_GetOptions( _context ) | JSOPTION_VAROBJFIX );
@@ -999,7 +999,7 @@ namespace mongo {
~SMScope(){
smlock;
- uassert( "deleted SMScope twice?" , _convertor );
+ uassert( 10223 , "deleted SMScope twice?" , _convertor );
for ( list<void*>::iterator i=_roots.begin(); i != _roots.end(); i++ ){
JS_RemoveRoot( _context , *i );
@@ -1056,7 +1056,7 @@ namespace mongo {
void externalSetup(){
smlock;
- uassert( "already local connected" , ! _localConnect );
+ uassert( 10224 , "already local connected" , ! _localConnect );
if ( _externalSetup )
return;
initMongoJS( this , _context , _global , false );
@@ -1065,9 +1065,9 @@ namespace mongo {
void localConnect( const char * dbName ){
smlock;
- uassert( "already setup for external db" , ! _externalSetup );
+ uassert( 10225 , "already setup for external db" , ! _externalSetup );
if ( _localConnect ){
- uassert( "connected to different db" , _localDBName == dbName );
+ uassert( 10226 , "connected to different db" , _localDBName == dbName );
return;
}
@@ -1135,7 +1135,7 @@ namespace mongo {
case JSTYPE_NUMBER: return NumberDouble;
case JSTYPE_BOOLEAN: return Bool;
default:
- uassert( "unknown type" , 0 );
+ uassert( 10227 , "unknown type" , 0 );
}
return 0;
}
@@ -1259,7 +1259,7 @@ namespace mongo {
uninstallCheckTimeout( timeoutMs );
if ( assertOnError )
- uassert( name + " exec failed" , worked );
+ uassert( 10228 , name + " exec failed" , worked );
if ( reportError && ! _error.empty() ){
// cout << "exec error: " << _error << endl;
@@ -1446,7 +1446,7 @@ namespace mongo {
return;
SMScope * scope = currentScope.get();
- uassert( "need a scope" , scope );
+ uassert( 10229 , "need a scope" , scope );
JSObject * o = JS_GetFunctionObject( f );
assert( o );
diff --git a/scripting/engine_v8.cpp b/scripting/engine_v8.cpp
index 1eda3d51667..3c736b32501 100644
--- a/scripting/engine_v8.cpp
+++ b/scripting/engine_v8.cpp
@@ -166,7 +166,7 @@ namespace mongo {
if ( v->IsNumber() )
return NumberDouble;
if ( v->IsExternal() ){
- uassert( "can't handle external yet" , 0 );
+ uassert( 10230 , "can't handle external yet" , 0 );
return -1;
}
if ( v->IsDate() )
@@ -205,7 +205,7 @@ namespace mongo {
Handle<Value> v = get( field );
if ( v->IsNull() || v->IsUndefined() )
return BSONObj();
- uassert( "not an object" , v->IsObject() );
+ uassert( 10231 , "not an object" , v->IsObject() );
return v8ToMongo( v->ToObject() );
}
@@ -252,7 +252,7 @@ namespace mongo {
}
Handle<Value> f = _global->Get( v8::String::New( fn.c_str() ) );
- uassert( "not a func" , f->IsFunction() );
+ uassert( 10232 , "not a func" , f->IsFunction() );
_funcs.push_back( f );
return num;
}
@@ -325,7 +325,7 @@ namespace mongo {
if (reportError)
log() << _error << endl;
if ( assertOnError )
- uassert( _error , 0 );
+ uassert( 10233 , _error , 0 );
return false;
}
@@ -335,7 +335,7 @@ namespace mongo {
if ( reportError )
log() << _error << endl;
if ( assertOnError )
- uassert( _error , 0 );
+ uassert( 10234 , _error , 0 );
return false;
}
diff --git a/scripting/sm_db.cpp b/scripting/sm_db.cpp
index 1c1a0b7bff1..62f88ed1ac7 100644
--- a/scripting/sm_db.cpp
+++ b/scripting/sm_db.cpp
@@ -65,12 +65,12 @@ namespace mongo {
DBClientCursor *getCursor( JSContext *cx, JSObject *obj ) {
CursorHolder * holder = (CursorHolder*)JS_GetPrivate( cx , obj );
- uassert( "no cursor!" , holder );
+ uassert( 10235 , "no cursor!" , holder );
return holder->get();
}
JSBool internal_cursor_constructor( JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval ){
- uassert( "no args to internal_cursor_constructor" , argc == 0 );
+ uassert( 10236 , "no args to internal_cursor_constructor" , argc == 0 );
assert( JS_SetPrivate( cx , obj , 0 ) ); // just for safety
return JS_TRUE;
}
@@ -120,7 +120,7 @@ namespace mongo {
// ------ mongo stuff ------
JSBool mongo_constructor( JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval ){
- uassert( "mongo_constructor not implemented yet" , 0 );
+ uassert( 10237 , "mongo_constructor not implemented yet" , 0 );
throw -1;
}
@@ -139,7 +139,7 @@ namespace mongo {
JSBool mongo_external_constructor( JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval ){
Convertor c( cx );
- uassert( "0 or 1 args to Mongo" , argc <= 1 );
+ uassert( 10238 , "0 or 1 args to Mongo" , argc <= 1 );
string host = "127.0.0.1";
if ( argc > 0 )
@@ -191,7 +191,7 @@ namespace mongo {
DBClientWithCommands *getConnection( JSContext *cx, JSObject *obj ) {
shared_ptr< DBClientWithCommands > * connHolder = (shared_ptr< DBClientWithCommands >*)JS_GetPrivate( cx , obj );
- uassert( "no connection!" , connHolder && connHolder->get() );
+ uassert( 10239 , "no connection!" , connHolder && connHolder->get() );
return connHolder->get();
}
@@ -211,9 +211,9 @@ namespace mongo {
};
JSBool mongo_find(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval){
- uassert( "mongo_find neesd 5 args" , argc == 5 );
+ uassert( 10240 , "mongo_find neesd 5 args" , argc == 5 );
shared_ptr< DBClientWithCommands > * connHolder = (shared_ptr< DBClientWithCommands >*)JS_GetPrivate( cx , obj );
- uassert( "no connection!" , connHolder && connHolder->get() );
+ uassert( 10241 , "no connection!" , connHolder && connHolder->get() );
DBClientWithCommands *conn = connHolder->get();
Convertor c( cx );
@@ -246,9 +246,9 @@ namespace mongo {
}
JSBool mongo_update(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval){
- uassert( "mongo_find needs at elast 3 args" , argc >= 3 );
- uassert( "2nd param to update has to be an object" , JSVAL_IS_OBJECT( argv[1] ) );
- uassert( "3rd param to update has to be an object" , JSVAL_IS_OBJECT( argv[2] ) );
+ uassert( 10242 , "mongo_find needs at elast 3 args" , argc >= 3 );
+ uassert( 10243 , "2nd param to update has to be an object" , JSVAL_IS_OBJECT( argv[1] ) );
+ uassert( 10244 , "3rd param to update has to be an object" , JSVAL_IS_OBJECT( argv[2] ) );
Convertor c( cx );
if ( c.getBoolean( obj , "readOnly" ) ){
@@ -257,7 +257,7 @@ namespace mongo {
}
DBClientWithCommands * conn = getConnection( cx, obj );
- uassert( "no connection!" , conn );
+ uassert( 10245 , "no connection!" , conn );
string ns = c.toString( argv[0] );
@@ -275,8 +275,8 @@ namespace mongo {
}
JSBool mongo_insert(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval){
- uassert( "mongo_insert needs 2 args" , argc == 2 );
- uassert( "2nd param to insert has to be an object" , JSVAL_IS_OBJECT( argv[1] ) );
+ uassert( 10246 , "mongo_insert needs 2 args" , argc == 2 );
+ uassert( 10247 , "2nd param to insert has to be an object" , JSVAL_IS_OBJECT( argv[1] ) );
Convertor c( cx );
if ( c.getBoolean( obj , "readOnly" ) ){
@@ -285,7 +285,7 @@ namespace mongo {
}
DBClientWithCommands * conn = getConnection( cx, obj );
- uassert( "no connection!" , conn );
+ uassert( 10248 , "no connection!" , conn );
string ns = c.toString( argv[0] );
@@ -311,8 +311,8 @@ namespace mongo {
}
JSBool mongo_remove(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval){
- uassert( "mongo_remove needs 2 arguments" , argc == 2 );
- uassert( "2nd param to insert has to be an object" , JSVAL_IS_OBJECT( argv[1] ) );
+ uassert( 10249 , "mongo_remove needs 2 arguments" , argc == 2 );
+ uassert( 10250 , "2nd param to insert has to be an object" , JSVAL_IS_OBJECT( argv[1] ) );
Convertor c( cx );
if ( c.getBoolean( obj , "readOnly" ) ){
@@ -321,7 +321,7 @@ namespace mongo {
}
DBClientWithCommands * conn = getConnection( cx, obj );
- uassert( "no connection!" , conn );
+ uassert( 10251 , "no connection!" , conn );
string ns = c.toString( argv[0] );
BSONObj o = c.toObject( argv[1] );
@@ -349,7 +349,7 @@ namespace mongo {
// ------------- db_collection -------------
JSBool db_collection_constructor( JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval ){
- uassert( "db_collection_constructor wrong args" , argc == 4 );
+ uassert( 10252 , "db_collection_constructor wrong args" , argc == 4 );
assert( JS_SetProperty( cx , obj , "_mongo" , &(argv[0]) ) );
assert( JS_SetProperty( cx , obj , "_db" , &(argv[1]) ) );
assert( JS_SetProperty( cx , obj , "_shortName" , &(argv[2]) ) );
@@ -432,7 +432,7 @@ namespace mongo {
JSBool db_constructor( JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval ){
- uassert( "wrong number of arguments to DB" , argc == 2 );
+ uassert( 10253 , "wrong number of arguments to DB" , argc == 2 );
assert( JS_SetProperty( cx , obj , "_mongo" , &(argv[0]) ) );
assert( JS_SetProperty( cx , obj , "_name" , &(argv[1]) ) );
@@ -484,7 +484,7 @@ namespace mongo {
oid.init();
}
else {
- uassert( "object_id_constructor can't take more than 1 param" , argc == 1 );
+ uassert( 10254 , "object_id_constructor can't take more than 1 param" , argc == 1 );
string s = c.toString( argv[0] );
try {
@@ -674,7 +674,7 @@ namespace mongo {
// dbquery
JSBool dbquery_constructor( JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval ){
- uassert( "DDQuery needs at least 4 args" , argc >= 4 );
+ uassert( 10255 , "DDQuery needs at least 4 args" , argc >= 4 );
Convertor c(cx);
c.setProperty( obj , "_mongo" , argv[0] );