MDN wants to learn about developers like you: https://qsurvey.mozilla.com/s3/MDN-dev-survey

SpiderMonkey/JSAPI_参考/JS_SetErrorReporter

指定一个程序的错误报告途径.

语法

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

文档标签和贡献者

 此页面的贡献者: ziyunfei, kunpeng
 最后编辑者: ziyunfei,