Skip to content

Instantly share code, notes, and snippets.

@mitchtabian
Created April 14, 2017 23:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mitchtabian/d56331996ea018d17c932f75069787f9 to your computer and use it in GitHub Desktop.
Save mitchtabian/d56331996ea018d17c932f75069787f9 to your computer and use it in GitHub Desktop.
FirebaseCrashReporting
/*
***Logging Type1***
*/
//to just log actions to the Firebase Dashboard you can use this
FirebaseCrash.log("Some message that you want to log");
//This type of logging is going to be analogous to this:
Log.d(TAG, "Some message that you want to log");
/*
***Logging Type2***
*/
//Surround sections of code in a try/catch to catch a specific type of error.
//In the example below I try to read a file that doesn't exist.
try{
File file = new File(filepath);
InputStream inputStream = new FileInputStream(file);
inputStream.read();
}catch (FileNotFoundException e){
FirebaseCrash.report(new Exception(
"FileNotFoundException in btnError2. Probably the filepath:" + filepath
));
} catch (IOException e) {
FirebaseCrash.report(new Exception(
e.toString()
));
}
/*
***Logging Type3***
*/
//This is just a default log that the Firebase Dashboard will get when the app crashes.
//You don't need to do anything it will do it automatically.
//this will throw an exception because the index is out of bounds
for (int i = 0; i <= theList.size(); i++){
Log.d(TAG, "onClick: theList: " + theList.get(i));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment