Bug 948647, part 2 - Rename js_ReportErrorAgain to js::CallErrorReporter (and other related tidying-up). r=Waldo.

--HG--
extra : rebase_source : 390a3f249982ed3b5843e78077bcd102e1366a48
This commit is contained in:
Jason Orendorff 2013-12-16 06:03:18 -06:00
parent 302fded0f2
commit 1f26ac383a
6 changed files with 23 additions and 53 deletions

View File

@ -579,18 +579,8 @@ CompileError::throwError(JSContext *cx)
// as the non-top-level "load", "eval", or "compile" native function
// returns false, the top-level reporter will eventually receive the
// uncaught exception report.
if (!js_ErrorToException(cx, message, &report, nullptr, nullptr)) {
// If debugErrorHook is present then we give it a chance to veto
// sending the error on to the regular error reporter.
bool reportError = true;
if (JSDebugErrorHook hook = cx->runtime()->debugHooks.debugErrorHook) {
reportError = hook(cx, message, &report, cx->runtime()->debugHooks.debugErrorHookData);
}
// Report the error.
if (reportError && cx->errorReporter)
cx->errorReporter(cx, message, &report);
}
if (!js_ErrorToException(cx, message, &report, nullptr, nullptr))
CallErrorReporter(cx, message, &report);
}
CompileError::~CompileError()

View File

@ -5913,15 +5913,6 @@ JS_ErrorFromException(JSContext *cx, HandleValue value)
return js_ErrorFromException(value);
}
JS_PUBLIC_API(bool)
JS_ThrowReportedError(JSContext *cx, const char *message,
JSErrorReport *reportp)
{
AssertHeapIsIdle(cx);
return JS_IsRunning(cx) &&
js_ErrorToException(cx, message, reportp, nullptr, nullptr);
}
JS_PUBLIC_API(bool)
JS_ThrowStopIteration(JSContext *cx)
{

View File

@ -4464,14 +4464,6 @@ JS_DropExceptionState(JSContext *cx, JSExceptionState *state);
extern JS_PUBLIC_API(JSErrorReport *)
JS_ErrorFromException(JSContext *cx, JS::HandleValue v);
/*
* Given a reported error's message and JSErrorReport struct pointer, throw
* the corresponding exception on cx.
*/
extern JS_PUBLIC_API(bool)
JS_ThrowReportedError(JSContext *cx, const char *message,
JSErrorReport *reportp);
/*
* Throws a StopIteration exception on cx.
*/

View File

@ -290,7 +290,9 @@ ReportError(JSContext *cx, const char *message, JSErrorReport *reportp,
JS_ASSERT(reportp);
if ((!callback || callback == js_GetErrorMessage) &&
reportp->errorNumber == JSMSG_UNCAUGHT_EXCEPTION)
{
reportp->flags |= JSREPORT_EXCEPTION;
}
/*
* Call the error reporter only if an exception wasn't raised.
@ -300,9 +302,9 @@ ReportError(JSContext *cx, const char *message, JSErrorReport *reportp,
* propagates out of scope. This is needed for compatibility
* with the old scheme.
*/
if (!JS_IsRunning(cx) ||
!js_ErrorToException(cx, message, reportp, callback, userRef)) {
js_ReportErrorAgain(cx, message, reportp);
if (!JS_IsRunning(cx) || !js_ErrorToException(cx, message, reportp, callback, userRef)) {
if (message)
CallErrorReporter(cx, message, reportp);
} else if (JSDebugErrorHook hook = cx->runtime()->debugHooks.debugErrorHook) {
/*
* If we've already chewed up all the C stack, don't call into the
@ -875,26 +877,21 @@ js_ReportErrorNumberUCArray(JSContext *cx, unsigned flags, JSErrorCallback callb
return warning;
}
JS_FRIEND_API(void)
js_ReportErrorAgain(JSContext *cx, const char *message, JSErrorReport *reportp)
void
js::CallErrorReporter(JSContext *cx, const char *message, JSErrorReport *reportp)
{
JSErrorReporter onError;
JS_ASSERT(message);
JS_ASSERT(reportp);
if (!message)
return;
onError = cx->errorReporter;
/*
* If debugErrorHook is present then we give it a chance to veto
* sending the error on to the regular ErrorReporter.
*/
if (onError) {
// If debugErrorHook is present, give it a chance to veto sending the error
// on to the regular ErrorReporter.
if (cx->errorReporter) {
JSDebugErrorHook hook = cx->runtime()->debugHooks.debugErrorHook;
if (hook && !hook(cx, message, reportp, cx->runtime()->debugHooks.debugErrorHookData))
onError = nullptr;
return;
}
if (onError)
if (JSErrorReporter onError = cx->errorReporter)
onError(cx, message, reportp);
}

View File

@ -784,14 +784,14 @@ ReportUsageError(JSContext *cx, HandleObject callee, const char *msg);
extern bool
PrintError(JSContext *cx, FILE *file, const char *message, JSErrorReport *report,
bool reportWarnings);
} /* namespace js */
/*
* Report an exception using a previously composed JSErrorReport.
* XXXbe remove from "friend" API
* Send a JSErrorReport to the errorReporter callback.
*/
extern JS_FRIEND_API(void)
js_ReportErrorAgain(JSContext *cx, const char *message, JSErrorReport *report);
void
CallErrorReporter(JSContext *cx, const char *message, JSErrorReport *report);
} /* namespace js */
extern void
js_ReportIsNotDefined(JSContext *cx, const char *name);

View File

@ -838,7 +838,7 @@ js_ReportUncaughtException(JSContext *cx)
/* Pass the exception object. */
JS_SetPendingException(cx, exn);
js_ReportErrorAgain(cx, bytes, reportp);
CallErrorReporter(cx, bytes, reportp);
}
JS_ClearPendingException(cx);