mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 13:25:37 +00:00
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:
parent
302fded0f2
commit
1f26ac383a
@ -579,18 +579,8 @@ CompileError::throwError(JSContext *cx)
|
|||||||
// as the non-top-level "load", "eval", or "compile" native function
|
// as the non-top-level "load", "eval", or "compile" native function
|
||||||
// returns false, the top-level reporter will eventually receive the
|
// returns false, the top-level reporter will eventually receive the
|
||||||
// uncaught exception report.
|
// uncaught exception report.
|
||||||
if (!js_ErrorToException(cx, message, &report, nullptr, nullptr)) {
|
if (!js_ErrorToException(cx, message, &report, nullptr, nullptr))
|
||||||
// If debugErrorHook is present then we give it a chance to veto
|
CallErrorReporter(cx, message, &report);
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CompileError::~CompileError()
|
CompileError::~CompileError()
|
||||||
|
@ -5913,15 +5913,6 @@ JS_ErrorFromException(JSContext *cx, HandleValue value)
|
|||||||
return js_ErrorFromException(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_PUBLIC_API(bool)
|
||||||
JS_ThrowStopIteration(JSContext *cx)
|
JS_ThrowStopIteration(JSContext *cx)
|
||||||
{
|
{
|
||||||
|
@ -4464,14 +4464,6 @@ JS_DropExceptionState(JSContext *cx, JSExceptionState *state);
|
|||||||
extern JS_PUBLIC_API(JSErrorReport *)
|
extern JS_PUBLIC_API(JSErrorReport *)
|
||||||
JS_ErrorFromException(JSContext *cx, JS::HandleValue v);
|
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.
|
* Throws a StopIteration exception on cx.
|
||||||
*/
|
*/
|
||||||
|
@ -290,7 +290,9 @@ ReportError(JSContext *cx, const char *message, JSErrorReport *reportp,
|
|||||||
JS_ASSERT(reportp);
|
JS_ASSERT(reportp);
|
||||||
if ((!callback || callback == js_GetErrorMessage) &&
|
if ((!callback || callback == js_GetErrorMessage) &&
|
||||||
reportp->errorNumber == JSMSG_UNCAUGHT_EXCEPTION)
|
reportp->errorNumber == JSMSG_UNCAUGHT_EXCEPTION)
|
||||||
|
{
|
||||||
reportp->flags |= JSREPORT_EXCEPTION;
|
reportp->flags |= JSREPORT_EXCEPTION;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Call the error reporter only if an exception wasn't raised.
|
* 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
|
* propagates out of scope. This is needed for compatibility
|
||||||
* with the old scheme.
|
* with the old scheme.
|
||||||
*/
|
*/
|
||||||
if (!JS_IsRunning(cx) ||
|
if (!JS_IsRunning(cx) || !js_ErrorToException(cx, message, reportp, callback, userRef)) {
|
||||||
!js_ErrorToException(cx, message, reportp, callback, userRef)) {
|
if (message)
|
||||||
js_ReportErrorAgain(cx, message, reportp);
|
CallErrorReporter(cx, message, reportp);
|
||||||
} else if (JSDebugErrorHook hook = cx->runtime()->debugHooks.debugErrorHook) {
|
} else if (JSDebugErrorHook hook = cx->runtime()->debugHooks.debugErrorHook) {
|
||||||
/*
|
/*
|
||||||
* If we've already chewed up all the C stack, don't call into the
|
* 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;
|
return warning;
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_FRIEND_API(void)
|
void
|
||||||
js_ReportErrorAgain(JSContext *cx, const char *message, JSErrorReport *reportp)
|
js::CallErrorReporter(JSContext *cx, const char *message, JSErrorReport *reportp)
|
||||||
{
|
{
|
||||||
JSErrorReporter onError;
|
JS_ASSERT(message);
|
||||||
|
JS_ASSERT(reportp);
|
||||||
|
|
||||||
if (!message)
|
// If debugErrorHook is present, give it a chance to veto sending the error
|
||||||
return;
|
// on to the regular ErrorReporter.
|
||||||
|
if (cx->errorReporter) {
|
||||||
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) {
|
|
||||||
JSDebugErrorHook hook = cx->runtime()->debugHooks.debugErrorHook;
|
JSDebugErrorHook hook = cx->runtime()->debugHooks.debugErrorHook;
|
||||||
if (hook && !hook(cx, message, reportp, cx->runtime()->debugHooks.debugErrorHookData))
|
if (hook && !hook(cx, message, reportp, cx->runtime()->debugHooks.debugErrorHookData))
|
||||||
onError = nullptr;
|
return;
|
||||||
}
|
}
|
||||||
if (onError)
|
|
||||||
|
if (JSErrorReporter onError = cx->errorReporter)
|
||||||
onError(cx, message, reportp);
|
onError(cx, message, reportp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -784,14 +784,14 @@ ReportUsageError(JSContext *cx, HandleObject callee, const char *msg);
|
|||||||
extern bool
|
extern bool
|
||||||
PrintError(JSContext *cx, FILE *file, const char *message, JSErrorReport *report,
|
PrintError(JSContext *cx, FILE *file, const char *message, JSErrorReport *report,
|
||||||
bool reportWarnings);
|
bool reportWarnings);
|
||||||
} /* namespace js */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Report an exception using a previously composed JSErrorReport.
|
* Send a JSErrorReport to the errorReporter callback.
|
||||||
* XXXbe remove from "friend" API
|
|
||||||
*/
|
*/
|
||||||
extern JS_FRIEND_API(void)
|
void
|
||||||
js_ReportErrorAgain(JSContext *cx, const char *message, JSErrorReport *report);
|
CallErrorReporter(JSContext *cx, const char *message, JSErrorReport *report);
|
||||||
|
|
||||||
|
} /* namespace js */
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
js_ReportIsNotDefined(JSContext *cx, const char *name);
|
js_ReportIsNotDefined(JSContext *cx, const char *name);
|
||||||
|
@ -838,7 +838,7 @@ js_ReportUncaughtException(JSContext *cx)
|
|||||||
|
|
||||||
/* Pass the exception object. */
|
/* Pass the exception object. */
|
||||||
JS_SetPendingException(cx, exn);
|
JS_SetPendingException(cx, exn);
|
||||||
js_ReportErrorAgain(cx, bytes, reportp);
|
CallErrorReporter(cx, bytes, reportp);
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_ClearPendingException(cx);
|
JS_ClearPendingException(cx);
|
||||||
|
Loading…
Reference in New Issue
Block a user