JS_ReportPendingException

Forward the current pending exception in a given JSContext to the current JSErrorReporter callback.

Syntax

JSBool JS_ReportPendingException(JSContext *cx);
Name Type Description
cx JSContext * The context in which the exception was thrown. Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext.

Description

If an exception is pending in the context cx, JS_ReportPendingException converts the exception to a string and reports it to the current error reporter.

On success, it clears the exception as though by calling JS_ClearPendingException and returns JS_TRUE. If no exception is pending, or if a second error occurs while trying to report the first one, it returns JS_FALSE.

This function can be used to catch exceptions thrown from scripts and send them to the error reporter to be logged or ignored. Note that certain JSAPI functions automatically do this for uncaught exceptions; see "Automatic handling of uncaught exceptions" in the JSAPI User Guide.

MXR ID Search for JS_ReportPendingException

Document Tags and Contributors

Contributors to this page: Jorend
Last updated by: Jorend,