JSErrorReporter JS_SetErrorReporter(JSContext *cx, JSErrorReporter er);
形式参数 类型 描述
cx JSContext * Pointer to a JS context from which to derive runtime information.
er JSErrorReporter 在你的程序中用于报告错误的自定义函数, 见下面的描述.


typedef void (*JSErrorReporter)(
    JSContext *cx, const char *message, JSErrorReport *report);
形式参数 类型 描述
cx JSContext * 错误发生的上下文。
message const char * 一个错误信息。
report JSErrorReport * 一个包含错误额外的详细资料报告记录。


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.

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.

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

MXR ID Search for JS_SetErrorReporter