Many of us or you can say everyone is using Crash Reporting in there application, whether it is Firebase Crash Reporting or Crashlytics or any other. I am using Firebase Crash Reporting in my project as I am using other Firebase features so it it quiet easier for me that everything is in one place. Well as many of you know implementing Firebase Crash Reporting in your application is quiet simple (here we are talking about Android Application as my knowledge is bound to only that point). You only have to add a dependency and everything starts to work. But, is it the only thing? Does my job is done with that?
Certainly not because crash reporting is not just that whenever your application crashes you got a log and you will fix it in the next release. It can be a major part but thats not all. Crash reporting is there so that your customer will not suffer when they use your application and you can do many things with that like Server side error debugging, knowing which Request breaks at what point, getting the exact cause of even handled exceptions and so more.
Now the question comes how. The answer is Non fatal crashes. Yes you heard it right. You had coded at least a hundreds of try-catch blocks in your code, obviously for exception handling. For a test-case you had missed while testing the application. So why not rather that only putting that code in try and implementing a catch as
1 2 3 4 |
catch (Exception e) { e.printStackTrace(); return new ArrayList(); } |
we should also log this as exception as Firebase Crash
1 2 3 4 5 6 |
catch (Exception e) { FirebaseCrash.log("Error while traversing list"); FirebaseCrash.report(e); e.printStackTrace(); return new ArrayList(); } |
The FirebaseCrash.log() method lets you add a custom log for the crash so you may get the required data to understand the crash or your own custom log message if you want. And the FirebaseCrash.report() method records that exception in the Crash Console on Firebase.
For Server side issues you can use the same code by reporting the error to Firebase crash whenever your connection fails or an exception / error is thrown by your server.
You can change every catch block of your application so you will get reports for even that handled exceptions that surely will enhance your customer experience with the application and will benefit you and your business.