okhttp - Interceptor - Stopping non-fatal exceptions from being logged to Crashlytics okhttp - Interceptor - Stopping non-fatal exceptions from being logged to Crashlytics android android

okhttp - Interceptor - Stopping non-fatal exceptions from being logged to Crashlytics


Non-fatal Exception is logged when you call Crashlytics.logException(Exception)explicitly in code

Please Read below information :

Crashlytics for Android lets you log caught exceptions in your app's catch blocks! To use this feature, simply add a call to Crashlytics.logException(Exception) to your catch block:

try {  myMethodThatThrows();} catch (Exception e) {  Crashlytics.logException(e);  // handle your exception here! }

All logged exceptions will appear as "non-fatal" issues in the Crashlytics dashboard. Your issue summary will contain all the state information you are use to getting from crashes along with breakdowns by Android version and hardware device.


Crashlytics only stores Non-fatal Exception when you use
Crashlytics.logException(), see the below code for interceptor , it's throwing IOException but exception will not be visible on dashboard on Non-fatal Exception section , while we not log it.

@Override public Response intercept(Interceptor.Chain chain) throws IOException {Request request = chain.request();long t1 = System.nanoTime();logger.info(String.format("Sending request %s on %s%n%s",    request.url(), chain.connection(), request.headers()));Response response = chain.proceed(request);long t2 = System.nanoTime();logger.info(String.format("Received response for %s in %.1fms%n%s",    response.request().url(), (t2 - t1) / 1e6d, response.headers()));return response;} 

so if you want to log the exception under Non-fatal Exception , just use Crashlytics.logException();

and Crashlytics only stores the most recent 8 exceptions in a given app session. If your app throws more than 8 exceptions in a session, older exceptions are lost.


Just search for Crashlytics.logException in your codebase, you will definitely find it somewhere. It is getting logged from there only.

Otherwise any exception on Response response = chain.proceed(request); will cause your app crash :)

Wild guess :), you might be using RxJava & in onError(throwable: Throwable) of your subscriber you might be logging it like below

override fun onError(throwable: Throwable) {       Crashlytics.logException(throwable) }