How to capture errors and send custom messages to Game Performance Reporting?

I’m trying to clean up our project and eliminate as many outstanding errors as possible. Game Performance reporting has been helpful to find the most common issues users encounter, but in some cases the error reported is not enough information for us to figure out exactly what’s wrong. He’s an example where we have a null exception firing within one of our coroutines, unfortunately there are a lot of moving parts within this call and we’re not exactly sure what’s wrong:
2970670--220639--Null.JPG

I can easily perform some basic null checking to prevent these errors from spamming the console but that doesn’t help us get to the root of what could be a larger issue. Ideally I want to be able to null check, and throw an error to Game Performance Reporting so we can see a custom message. I might be reading it incorrectly but it seems that if I wrap code in a try-catch block and throw my own errors that these messages will not be captured by Game Performance Reporting.

Do you have a recommended practice for how I can get more information on an error like this? I was looking for something roughly like this:

if(testObj == null)
{
    throw custom error to Game Performance Reporting ("blah blah")
    return;
}

// continue normal logic here


if(testObj2 == null)
{
    throw custom error to Game Performance Reporting ("yada yada")
    return;
}

Hi TitanUnity,

You can use Debug.LogException to report any exception to the Game Performance service.

if(testObj == null)
{
    Debug.LogException(new Exception("testObj was null"));
    return;
}

It accepts any type that derives from Exception.

Oh perfect, thanks a bunch.

Hello Thomas,

I was searching on Google for this same question and I found your answer. My suggestion is that you include a method call in the PerformanceReporting class (or Analytics class) as a stub for the LogException() method - sort of a shortcut.

This will save time to a lot of devs that are not aware it works this way.

Thanks!

So Debug.LogException is not removed when building a release build?