0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

better error messages

This commit is contained in:
Eliot Horowitz 2009-08-28 16:56:34 -04:00
parent ba0f9ce5ac
commit 3f1d5ad8d4

View File

@ -304,15 +304,16 @@ namespace mongo {
return true; return true;
} }
void addRoot( JSFunction * f ); void addRoot( JSFunction * f , const char * name );
JSFunction * compileFunction( const char * code, JSObject * assoc = 0 ){ JSFunction * compileFunction( const char * code, JSObject * assoc = 0 ){
JSFunction * f = _compileFunction( code , assoc ); const char * gcName = "unknown";
addRoot( f ); JSFunction * f = _compileFunction( code , assoc , gcName );
addRoot( f , gcName );
return f; return f;
} }
JSFunction * _compileFunction( const char * raw , JSObject * assoc ){ JSFunction * _compileFunction( const char * raw , JSObject * assoc , const char *& gcName ){
while (isspace(*raw)) { while (isspace(*raw)) {
raw++; raw++;
} }
@ -322,6 +323,7 @@ namespace mongo {
if ( isSimpleStatement( s ) ){ if ( isSimpleStatement( s ) ){
s = "return " + s; s = "return " + s;
} }
gcName = "cf anon";
return JS_CompileFunction( _context , assoc , "anonymous" , 0 , 0 , s.c_str() , strlen( s.c_str() ) , "nofile_a" , 0 ); return JS_CompileFunction( _context , assoc , "anonymous" , 0 , 0 , s.c_str() , strlen( s.c_str() ) , "nofile_a" , 0 );
} }
@ -364,6 +366,7 @@ namespace mongo {
cerr << "compile failed for: " << raw << endl; cerr << "compile failed for: " << raw << endl;
return 0; return 0;
} }
gcName = "cf normal";
return func; return func;
} }
@ -1350,7 +1353,7 @@ namespace mongo {
return new SMScope(); return new SMScope();
} }
void Convertor::addRoot( JSFunction * f ){ void Convertor::addRoot( JSFunction * f , const char * name ){
if ( ! f ) if ( ! f )
return; return;
@ -1359,7 +1362,7 @@ namespace mongo {
JSObject * o = JS_GetFunctionObject( f ); JSObject * o = JS_GetFunctionObject( f );
scope->addRoot( &o , "cf" ); scope->addRoot( &o , name );
} }
} }