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

2

16

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)?

Cheshire answered 27/9, 2017 at 7:6 Comment(0)
R
9

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);
    }
}
Radke answered 5/10, 2018 at 9:26 Comment(0)
L
4

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.

Lipchitz answered 27/9, 2017 at 13:29 Comment(3)
Thanks for your answer. Will try to do something with custom exception types, although it's pretty difficult because there are about 120 error codes and our app doesn't have to handle most of them but just display exception message received from the server. Exception messages are different for every API response. But Crashlytics doesn't take it into consideration, as I see. This would be good. Actually, custom grouping itself would be a nice feature request, too :)Cheshire
Thanks for the details and feedback! We don't have immediate plans to add in custom grouping, but will share your desire for this with the team.Lipchitz
In an Android project, I'm using Timber and Timber.e and then having the release version of TimberTree do override fun log(priority: Int...) { if (priority == ERROR) Crashlytics.logException(t ?: Exception(message)) }. The issue then is that the logs all get lumped together. It would be nice if you could do something like ask fabric to ignore certain parts of the log trace like timber.log.Timber and com.my.app.TimberTree to split the non-fatals down.Disingenuous

© 2022 - 2024 — McMap. All rights reserved.