Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to split/ungroup Crashlytics non-fatal exceptions report using custom attribute?

I send to Crashlytics errors I get during sync with server. These errors mostly contain info about different data conflicts. All errors are wrapped into one exception class which has fields like apiErrorCode. I can't create separate exception class for every error because there are dosens of them. So, all such exceptions that I send using Crashlytics.logException() are grouped into one report on dashboard. So I have to go to "All sessions" and investigate errors one by one there, which is not convenient. Also I cannot close and lock some error types I don't want to see in reports (like some expected server errors). Is it a way to manually set Crashlytics grouping strategy (based on apiErrorCode in my case)?

like image 681
Bringoff Avatar asked Sep 27 '17 07:09

Bringoff


2 Answers

If you have different kind of exceptions coming from one stacktrace you can change stacktrace by adding one more custom element to top:

public class CustomException extends Exception {

    public CustomException(String message, int lineNumber) {
        super(message);
        StackTraceElement[] stackTrace = getStackTrace();
        StackTraceElement[] newStackTrace = new StackTraceElement[stackTrace.length + 1];
        System.arraycopy(stackTrace, 0, newStackTrace, 1, stackTrace.length);
        newStackTrace[0] = new StackTraceElement("className", "methodName", "fileName", lineNumber);
        setStackTrace(newStackTrace);
    }
}
like image 146
Andoctorey Avatar answered Nov 10 '22 13:11

Andoctorey


Mike from Fabric here. There isn't a way to override the grouping that we do on logged errors. I recommended being specific with the exception type and message instead of using a single exception class though that does come with the trade-off of increased code complexity.

like image 3
Mike Bonnell Avatar answered Nov 10 '22 13:11

Mike Bonnell