接入bugly js异常时,报JS_SetErrorReporter没定义 我看scriptCore里确实也没有 ,这是在creator里去掉了?
用 JS::SetWarningReporter
引擎中内置Bugly?哪个版本开始的?
没有的事
SetWarningReporter(JSContext* cx, WarningReporter reporter);
using WarningReporter = void ()(JSContext cx, JSErrorReport* report);
但是bugly
void BuglyJSAgent::reportJSError(JSContext *cx, const char *message, JSErrorReport *report)
JS::SetWarningReporter(cx, BuglyJSAgent::reportJSError);
这样用JS::SetWarningReporter不对啊,少了个参数 ,应该是bugly想打印堆栈信息
主要原因是 bugly sdk 中使用的 API 在 Spidermonkey v52 中已经不提供了,这个引擎也控制不了,麻烦把错误反馈给 bugly 一下
我看了论坛里一篇Creator1.7接入Bugly 的帖子,里面用到的异常捕获是
// bugly: 设置JS的异常上报
se->setExceptionCallback([](const char* location, const char* message, const char* stack){
// Send exception information to server like Tencent Bugly.
CrashReport::reportException(CATEGORY_JS_EXCEPTION, “JSException”, message, stack);
});
而官方提供的是
这两个接口,js异常捕获按官方文档提示还要导入
这两个文件 。。但是我导入后这里文件各种报错。。
接口换了,貌似没更新吧
大兄弟,请问这个问题解决了吗?
刚刚也碰到了这个问题,稍微修改了一下,有3处地方,至少能跑起来:
BuglyJSAgent.h里面添加一行(没错,就是拷贝之前的,把中间的message参数删掉):
static void reportJSError(JSContext *cx, JSErrorReport *report);
BuglyJSAgent.cpp里面添加实现:
void BuglyJSAgent::reportJSError(JSContext *cx, JSErrorReport *report){
reportJSError(cx, “error”, report);
}
修改:JS_SetErrorReporter(cx, BuglyJSAgent::reportJSError);
变为:JS::SetWarningReporter(cx, BuglyJSAgent::reportJSError);
以上,希望能有所帮助。
大兄弟,问题解决了吗?


