Summary: Ctors | Methods | Protected Methods | Inherited Methods | [Expand All]
public class

# StandardExceptionParser

extends Object
implements ExceptionParser

java.lang.Object
↳ | com.google.android.gms.analytics.StandardExceptionParser

## Class Overview

This class will capture the root cause (last in a chain of causes) `Throwable` and report the exception type, class name, method name and thread name.

This class will attempt to report a class and method name that is relevant to the application if at all possible. It does this by finding the root cause `Throwable`, then checking each `StackTraceElement` for a class that is in a package list created by `setIncludedPackages(Context, Collection)`, starting with the first `StackTraceElement`.

The `String` returned by `getDescription(String, Throwable)` will take the form Exception class(@classname:methodname){threadname}.

See `getBestStackTraceElement(Throwable)` and `setIncludedPackages(Context, Collection)` for details.

## Summary

Public Constructors
| StandardExceptionParser(Context context, Collection<String> additionalPackages)

Public Methods
String | getDescription(String threadName, Throwable t) Return a short description of a `Throwable` suitable for reporting to Google Analytics.
void | setIncludedPackages(Context context, Collection<String> additionalPackages) Sets the list of packages considered relevant to the list of packages in the `Context` and the list of packages provided in the input parameter `additionalPackages`.

Protected Methods
StackTraceElement | getBestStackTraceElement(Throwable t) Return the first `StackTraceElement` found that has a className in any packageName found in `includedPackages`.
Throwable | getCause(Throwable t) Get the root cause of the input `Throwable`.
String | getDescription(Throwable cause, StackTraceElement element, String threadName) Given input of a `Throwable`, a `StackTraceElement` and the name of the `Thread`, return a `String` describing the `Throwable` and the name of the `Class` and method where the `Throwable` happened.

[Expand] Inherited Methods
From class java.lang.Object
Object | clone()
boolean | equals(Object arg0)
void | finalize()
final Class<?> | getClass()
int | hashCode()
final void | notify()
final void | notifyAll()
String | toString()
final void | wait(long arg0, int arg1)
final void | wait(long arg0)
final void | wait()
From interface com.google.android.gms.analytics.ExceptionParser
abstract String | getDescription(String threadName, Throwable t) Return a short description of a `Throwable` suitable for reporting to Google Analytics.

## Public Constructors

#### public StandardExceptionParser (Context context, Collection<String> additionalPackages)

## Public Methods

#### public String getDescription (String threadName, Throwable t)

Return a short description of a `Throwable` suitable for reporting to Google Analytics.

##### Parameters

threadName | the name of the `Thread` that got the exception, or null
t | the `Throwable`

##### Returns

- the description

#### public void setIncludedPackages (Context context, Collection<String> additionalPackages)

Sets the list of packages considered relevant to the list of packages in the `Context` and the list of packages provided in the input parameter `additionalPackages`. Either parameter can be null.

Any package names stored from a previous call to this method will be cleared.

##### Parameters

context | any `Context` for the application
additionalPackages | a collection of additional package names to add

## Protected Methods

#### protected StackTraceElement getBestStackTraceElement (Throwable t)

Return the first `StackTraceElement` found that has a className in any packageName found in `includedPackages`. If none have a className in any packageName found in `includedPackages`, return the first `StackTraceElement` found. If the `Throwable` does not contain any `StackTraceElement`s, return null.

#### protected Throwable getCause (Throwable t)

Get the root cause of the input `Throwable`. This method chains through each cause of the original input and returns the last cause in the chain.

##### Parameters

t | the initial `Throwable`

##### Returns

- the root cause

#### protected String getDescription (Throwable cause, StackTraceElement element, String threadName)

Given input of a `Throwable`, a `StackTraceElement` and the name of the `Thread`, return a `String` describing the `Throwable` and the name of the `Class` and method where the `Throwable` happened. The `String` returned will also have the name of the thread appended (as provided in the input parameter threadName).