How to effectively group non-fatal exceptions in Crashlytics (Fabrics)?

We use Crashlytics in our application as a crash reporting tool. For Android's own crashes, it works fine and groups faults correctly. Our application also has several components of its kind. For crashes that occur in these components, we catch them and then register them in Crashlytics as non-fatal exceptions.

public class PlatformNativeModuleCallExceptionhandler implements 
NativeModuleCallExceptionHandler {
@Override
public void handleException(Exception e) {
    try {
        .
        .
        .
        Crashlytics.logException(new Exception(exceptionString));
    } catch (Exception ex) {}
}

Crashes are logged in the Crashlytics dashboard, but it displays all crashes in one tab. These may be different malfunctions of the same or different reacting components.

enter image description here

Because of this, we cannot detect cases of a specific failure. You must manually go through each case of failure.

, , , PlatformNativeModuleCallExceptionHandler. , .

- , ? .

+8
4

Crashlytics , , , . .

+4

Crashlytics , , . , . , Crashlytics.

:

public void crashlyticsIsGarbage(String exceptionString) {
    Exception exception = null;
    switch(exceptionString) {
        case "string1": exception = new String1Exception(exceptionString);
        case "string2": exception = new String2Exception(exceptionString);
        case "string3": exception = new String3Exception(exceptionString);
        case "string4": exception = new String4Exception(exceptionString);
        default: exception = new Exception(exceptionString);
    }
    Crashlytics.logException(exception);
}

class String1Exception extends Exception { String1Exception(String exceptionString) { super(exceptionString); } }
class String2Exception extends Exception { String2Exception(String exceptionString) { super(exceptionString); } }
class String3Exception extends Exception { String3Exception(String exceptionString) { super(exceptionString); } }
class String4Exception extends Exception { String4Exception(String exceptionString) { super(exceptionString); } }

BTW, Crashlytics Exception.

+2

, . new Exception(exceptionMessage) , , , catch handleException() handleException() , exceptionMessage. Message exception.setStackTrace(). , , , , .

+2

, :

.

: , , , . . Crashlytics . .

. , , , :

, , , , .

:

public static Throwable getRootCause(Throwable throwable) {
    Throwable cause = throwable;
    while (cause.getCause() != null) {
        cause = cause.getCause();
    }
    return cause;
}

, :

@Override
public void handleException(Exception e) {
    // ...
    Crashlytics.logException(e);
}

.

, :

@Override
public void handleException(Exception e) {
    // ...
    Crashlytics.logException(new Exception(exceptionString, e));
}

, e , , , , , , .

Finally, unlike what Miguel said , the type of exception or message does not affect the grouping in my experience. If you have FooException("foo")a particular line in a specific method and you replace it with BarException("bar"), the two will be grouped together because the line and method have not changed.

0
source

Source: https://habr.com/ru/post/1690261/


All Articles