Error Tracking

  • An ‘error’ is a designed error state in your app, such as a failed login.
  • An ‘exception’ is an error thrown by the app or site.

Additional attributes can be sent with a logError or logException command.

Log Errors

Dictionary<string, string> errorInfo = new Dictionary<string, string> ();		
errorInfo.Add ("reason", "Invalid username");		

MParticle.Instance.LogError ("Login failed", errorInfo);		

Log Exceptions

try		
{		
    SomeDangerousMethod ();		
}		
catch (NullReferenceException e)		
{		
    MParticle.Instance.LogException (e);		
}		

While debugging a scenario that may lead or is currently leading to crashes and/or exceptions, it is often helpful to leave breadcrumbs along the way to better understand the context leading to the problem. Things like which interactions a user had with the app, or to identify step-by-step what led to a particular line of code being executed.

The mParticle SDK lets you leave breadcrumbs with the leaveBreadcrumb method. You can also include additional custom attributes.

//fictional method that parses some object		
private void ParseResource (Resource someResource)		
{		
    try		
    {		
        MParticle.Instance.LeaveBreadcrumb ("Parsing began");		

        MParticle.Instance.LeaveBreadcrumb ("parsing title");		
        Par seResourceTitle (someResource);		

        MParticle.Instance.LeaveBreadcrumb ("parsing body");		
        ParseResourceBody (someResource);		

        MParticle.Instance.LeaveBreadcrumb ("parsing footer");		
        ParseResourceFooter (someResource);		

        MParticle.Instance.LeaveBreadcrumb ("parsing finished!");		
    }		
    catch (Exception ex)		
    {		
        MParticle.Instance.LogException (ex);		
    }		
}