Use a non-bogus error reporter for the subscript loader. Bug 340019, r=mrbkap,

sr=brendan
This commit is contained in:
bzbarsky%mit.edu 2006-06-10 00:47:40 +00:00
Родитель 2d57e36b6b
Коммит df6ecca50e
2 изменённых файлов: 8 добавлений и 64 удалений

Просмотреть файл

@ -103,8 +103,8 @@ static PRLogModuleInfo *gJSCLLog;
#define LOG(args) PR_LOG(gJSCLLog, PR_LOG_DEBUG, args)
JS_STATIC_DLL_CALLBACK(void)
Reporter(JSContext *cx, const char *message, JSErrorReport *rep)
void JS_DLL_CALLBACK
mozJSLoaderErrorReporter(JSContext *cx, const char *message, JSErrorReport *rep)
{
nsresult rv;
@ -562,7 +562,7 @@ mozJSComponentLoader::LoadModule(nsILocalFile* aComponentFile,
return rv;
}
JSCLAutoErrorReporterSetter aers(cx, Reporter);
JSCLAutoErrorReporterSetter aers(cx, mozJSLoaderErrorReporter);
jsval argv[2], retval, NSGetModule_val;
@ -932,7 +932,7 @@ mozJSComponentLoader::GlobalForLocation(nsILocalFile *aComponent,
rv = mRuntimeService->GetBackstagePass(getter_AddRefs(backstagePass));
NS_ENSURE_SUCCESS(rv, rv);
JSCLAutoErrorReporterSetter aers(cx, Reporter);
JSCLAutoErrorReporterSetter aers(cx, mozJSLoaderErrorReporter);
nsCOMPtr<nsIXPConnect> xpc =
do_GetService(kXPConnectServiceContractID, &rv);

Просмотреть файл

@ -65,65 +65,9 @@ static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
#define LOAD_ERROR_BADREAD "File Read Error."
#define LOAD_ERROR_READUNDERFLOW "File Read Error (underflow.)"
/* turn ALL JS Runtime errors into exceptions */
JS_STATIC_DLL_CALLBACK(void)
ExceptionalErrorReporter (JSContext *cx, const char *message,
JSErrorReport *report)
{
JSObject *ex;
JSString *jstr;
JSBool ok;
if (report && JSREPORT_IS_EXCEPTION (report->flags))
/* if it's already an exception, our job is done. */
return;
ex = JS_NewObject (cx, nsnull, nsnull, nsnull);
/* create a jsobject to throw */
if (!ex)
goto panic;
/* decorate the exception */
if (message)
{
jstr = JS_NewStringCopyZ (cx, message);
if (!jstr)
goto panic;
ok = JS_DefineProperty (cx, ex, "message", STRING_TO_JSVAL(jstr),
nsnull, nsnull, JSPROP_ENUMERATE);
if (!ok)
goto panic;
}
if (report)
{
jstr = JS_NewStringCopyZ (cx, report->filename);
if (!jstr)
goto panic;
ok = JS_DefineProperty (cx, ex, "fileName", STRING_TO_JSVAL(jstr),
nsnull, nsnull, JSPROP_ENUMERATE);
if (!ok)
goto panic;
ok = JS_DefineProperty (cx, ex, "lineNumber",
INT_TO_JSVAL(NS_STATIC_CAST(uintN,
report->lineno)),
nsnull, nsnull, JSPROP_ENUMERATE);
if (!ok)
goto panic;
}
JS_SetPendingException (cx, OBJECT_TO_JSVAL(ex));
return;
panic:
#ifdef DEBUG
fprintf (stderr,
"mozJSSubScriptLoader: Error occurred while reporting error :/\n")
#endif
;
}
// We just use the same reporter as the component loader
extern void JS_DLL_CALLBACK
mozJSLoaderErrorReporter(JSContext *cx, const char *message, JSErrorReport *rep);
mozJSSubScriptLoader::mozJSSubScriptLoader() : mSystemPrincipal(nsnull)
{
@ -333,7 +277,7 @@ mozJSSubScriptLoader::LoadSubScript (const PRUnichar * /*url*/
/* set our own error reporter so we can report any bad things as catchable
* exceptions, including the source/line number */
er = JS_SetErrorReporter (cx, ExceptionalErrorReporter);
er = JS_SetErrorReporter (cx, mozJSLoaderErrorReporter);
ok = JS_EvaluateScriptForPrincipals (cx, target_obj, jsPrincipals,
buf, len, url, 1, rval);