toto_tata
toto_tata

Reputation: 15392

Google Analytics Android SDK / Exceptions report : "myParser represents your implementation of ExceptionParser"

I have implemented in my project the exception reporting feature of Google Analytics (Android SDK) described here :

https://developers.google.com/analytics/devguides/collection/android/v2/exceptions?hl=fr

I would like to use ExceptionParser as explained at the bottom of the page but I don't understand what they mean by :

// Where myParser represents your implementation of ExceptionParser.
ExceptionParser parser = new myParser(context);

What should I write in the myParser class ?? Why this class is not part of the Google Analytics SDK ?

Thanks !

Upvotes: 0

Views: 656

Answers (2)

toto_tata
toto_tata

Reputation: 15392

Thanks !

I used Andy Res answer. My full getDescription method is :

public String getDescription(String threadName, Throwable t) {
        // TODO Auto-generated method stub

        String description = "threadName = "
        + threadName
        + "\ngetMessage()= " + t.getMessage()
        + "\ngetLocalizedMessage()=" + t.getLocalizedMessage()
        + "\ngetCause()=" + t.getCause()
        + "\ngetStackTrace()=" + t.getStackTrace();

        return description;

    }

Upvotes: 1

Andy Res
Andy Res

Reputation: 16043

They say that ExceptionParser is an interface and has only 1 method: getDescription(String threadName, Throwable t).

So, to get the most relevant description of the exception you may create a new class that implements that interface and overrides getDescription().

Something like this:

public class MyParser implements ExceptionParser{
   @Override
   public String getDescription(String threadName, Throwable t){
      return threadName+", "+t.get..... 
   }
}

(Note that I'm not sure that return type of getDescription() is String. You should put the appropriate return type)

Upvotes: 2

Related Questions