JS_SetErrorReporter

Specify the error reporting mechanism for an application.

Syntax

JSErrorReporter JS_SetErrorReporter(JSContext *cx, JSErrorReporter er);
Name Type Description
cx JSContext * Pointer to a JS context whose errors should be reported via your function. Other contexts in the same runtime can have their own error reporting functions.
er JSErrorReporter The user-defined error reporting function to use in your application, described below.

Callback Syntax

typedef void (*JSErrorReporter)(
    JSContext *cx, const char *message, JSErrorReport *report);
Name Type Description
cx JSContext * The context in which the error happened.
message const char * An error message.
report JSErrorReport * An error report record containing additional details about the error.

Description

JS_SetErrorReporter enables you to define and use your own error reporting mechanism in your applications. The reporter you define is automatically passed a JSErrorReport structure when an error occurs and has been parsed by JS_ReportError. JS_SetErrorReporter returns the previous error reporting function of the context, or NULL if no such function had been set.

Typically, the error reporting mechanism you define should log the error where appropriate (such as to a log file), and display an error to the user of your application. The error you log and display can make use of the information passed about the error condition in the JSErrorReport structure.

The error reporter callback must not reenter the JSAPI. Like all other SpiderMonkey callbacks, the error reporter callback must not throw a C++ exception.

MXR ID Search for JS_SetErrorReporter

Document Tags and Contributors

Contributors to this page: MMondor, Dria, Jorend, KON
Last updated by: KON,