How to catch [SE_ERROR] along with the complete message?

Hello everyone,

In this situation, I aim to capture [SE_ERROR] occurrences, similar to what I observed in the Android Studio log.

I’ve already added setJSExceptionCallback in CocosApplication.cpp like this:

se->setJSExceptionCallback([](const char *location, const char *message, const char *stack) {
    std::string evalStr = "window.crashReport('nJavaScript Exception: \\n - location : " + std::string(location) + "\\n - msg : " + std::string(message) + "\\n - detail : \\n      " + std::string(stack) + "')";
    se::ScriptEngine::getInstance()->evalString(evalStr.c_str());
    se::ScriptEngine::getInstance()->evalString("console.error('JSEXCEPTION')");
});

However, it doesn’t seem to work.

If I use try-catch on my TS script, I only receive the message “TypeError: Cannot set property ‘spriteFrame’ of null”. I need the full error message for reporting to Crashlytics.

Does anyone have an idea about this situation?
Thank you

You can do that at in TS only

let consoleError = window.console.error;
window.console.error = function () {
     console.log("=======>", JSON.stringify(arguments));
     // sendFirebaseCrashLog(arguments);
     consoleError && consoleError.apply(window, arguments);
}

But question is how will you send to Crashlytics??

Hi, thank you very much for your response.
I’ve already tried that, but the code doesn’t seem to catch errors like the one mentioned: TypeError: Cannot set property 'spriteFrame' of null.

In my implementation, I simply need to call recordException like this:

public void recordException(String message) {
    crashlytics.recordException(new Exception(message));
}

and ensure that you’ve set setCrashlyticsCollectionEnabled to true in onCreate .

I am using same only for my project :slight_smile: Only thing is all crashes will be reported in same thread

BTW its working fine for me in above example, i am using 3.5.2

I hope for official Firebase support in the future :smile:

Is that so? I’m using version 3.8.0, but it doesn’t seem to work for me.